(4)A selection of tips

招数4:

精选的技巧

Make sure HTTP compression is turned on for any uncompressed content. HTML in particular compresses significantly, and in this era of mobile friendliness and slow 3G connections, that’s essential.
确保为未压缩的内容打开HTTP压缩。在这个面向移动友好和3G连接缓慢的时代,HTML压缩尤其明显,这是至关重要的。

(5)Always set the CacheControlMaxAge attribute in web.config to a high number (a year is good). You don’t want people pulling down the same static content they did last week. It’ll also save on the bandwidth you’re paying for.

招数5:

总是在web.config中CacheControlMaxAge属性设置为一个很高的数值(一年比较好)。你不想人们总是取回上周就取回的相同的静态内容。这会为你节约宽带费用的开销。

(6)Make use of the OutputCache annotation on MVC controllers. If the server can serve from memory, rather than going to disk or database, that’s a good win.

招数6:

在MVC 控制器上使用OutputCache标识。如果服务能从内存中获取能比从磁盘和数据库获得更好的性能。

(7)Always profile your ORM database hits with SQL Profiler during development. ORMs get away from you very quickly. Before you know it, you’ve run a query 2000 times in a loop, when you could have retrieved all your data with a single database hit.

招数7:

总是在开发中使用SQL Profiler分析你的ORM数据库访问。ORMs让你远离了SQL查询。在你了解它以前,你已经在一个循环中运行2000次查询,其实你可以在一次数据库访问中获取所有的数据。

(8)Watch out for lazy loading in ORMs. You shouldn’t lazy load any entities that could be retrieved with a single database hit.

招数8:

注意ORMs中的延迟加载。你不应该延迟加载任何实体而是一次数据库访问取回它们。

(9)Implement different database queries in different contexts. In the API and on a webpage, you’ll inevitably require different entity properties, so don’t load things you don’t need just because it’s convenient to reuse a query.

招数9:

在不同的上下文实现不同的数据库访问。你不可避免的需要不同的实体属性,不需要加载你不需要的东西仅仅为了方便重用查询。

(10)Get MiniProfiler and configure it to always run when you hit your site (just don’t enable it for the general public). You’ll get detailed execution times and a big red warning if the same database query is running multiple times.

招数10:

当你访问你的站点时候(在公之于众之前启用它),获取MiniProfiler并且设置为总是运行。你会得到详细的运行时间和一个显眼红色警告(如果同一个数据库查询运行了多次)。

教你50招提升ASP.NET性能(四):精选的技巧的更多相关文章

  1. 教你50招提升ASP.NET性能(二十六):对于开发人员的数据库性能技巧

    Database Performance Tips for Developers对于开发人员的数据库性能技巧 As a developer you may or may not need to go ...

  2. 教你50招提升ASP.NET性能(十六):把问题仍给硬件而不是开发人员

    (27)Throw hardware at the problem, not developers 招数27: 把问题仍给硬件而不是开发人员 As developers, we often want ...

  3. 教你50招提升ASP.NET性能(十一):避免在调试模式下运行网站

    (17)Avoid running sites in debug mode 招数17: 避免在调试模式下运行网站 When it comes to ASP.NET, one of the most c ...

  4. 教你50招提升ASP.NET性能(七):总是在服务器端执行验证

    (13)Always perform validation on the server as well 招数13: 总是在服务器端执行验证 This isn’t exactly a performan ...

  5. 教你50招提升ASP.NET性能(二):移除不用的视图引擎

    (2)Remove unused View Engines 招数2: 移除不用的视图引擎 If you're an ASP.NET MVC developer, you might not know ...

  6. 教你50招提升ASP.NET性能(二十四):ORM小窍门

    ORM TipsORM小窍门 More and more people are using Object to Relational Mapping (ORM) tools to jump the d ...

  7. 教你50招提升ASP.NET性能(二十一):避免使用会话状态

    (39)Avoid using session state 招数39: 避免使用会话状态 Where possible, you should try and avoid using session ...

  8. 教你50招提升ASP.NET性能(二十):7条便利的ViewState技巧

    (32)Seven handy ViewState tips 招数32: 7条便利的ViewState技巧 Every time I have to deal with a classic ASP.N ...

  9. 教你50招提升ASP.NET性能(十九):静态集合

    (30)Static collections 招数30: 静态集合 If a collection is static, make sure it only contains the objects ...

随机推荐

  1. AOSP

    定义编辑 "Android Open-Source Project"的缩写 中文意为"Android 开放源代码项目" 内容编辑 在Android Open-S ...

  2. linux 用grep匹配横线

    file的内容如下: ADSFADSFSDFASDFJKJK----------------------------------------ADSFADSFSDFASDFJKJK----------- ...

  3. Java之Comparable接口和Comparator接口

    Comparable & Comparator 都是用来实现集合中元素的比较.排序的: Comparable 是在集合内部定义的方法实现的排序: Comparator 是在集合外部实现的排序: ...

  4. xss(跨站脚本攻击),crsf(跨站请求伪造),xssf

    我们常说的网络安全其实应该包括以下三方面的安全: 1.机密性,比如用户的隐私被窃取,帐号被盗,常见的方式是木马. 2.完整性,比如数据的完整,举个例子,康熙传位十四子,被当时四阿哥篡改遗诏:传位于四子 ...

  5. Eclipse文件编码设置的问题

    Eclipse中设置编码的方式 如果要使插件开发应用能有更好的国际化支持,能够最大程度的支持中文输出, 则最好使 Java文件使用UTF-8编码.然而,Eclipse工作空间(workspace)的缺 ...

  6. 每天学点linux命令--tail,cut,sort,uniq

    tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不但刷新, ...

  7. 房租管理小软件(七):flowlayoutPancel 中增加分类控

    见下图的 string FNodeName = dt.Rows[i]["FNodeName"].ToString(); ) { RoomControl.Thumbnail.Grou ...

  8. TCP 3次握手和四次挥手

    1.标示符说明    位码即tcp标志位: SYN(synchronous建立联机)   ACK(acknowledgement 确认)  PSH(push传送)    FIN(finish结束)   ...

  9. uva 10652

    大意:有n块矩形木板,你的任务是用一个面积尽量小的凸多边形把它们包起来,并计算出木板站整个包装面积的百分比. 思路:按照题意将所有矩形顶点坐标存起来,旋转时先旋转从中心出发的向量,求得各个坐标之后,求 ...

  10. android NDK 实用学习(三)- java端类对象的构造及使用

    1,读此文章前我假设你已经读过: android NDK 实用学习-获取java端类及其类变量 android NDK 实用学习-java端对象成员赋值和获取对象成员值 2,java端类对象的构造: ...