教你50招提升ASP.NET性能(四):精选的技巧
(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性能(四):精选的技巧的更多相关文章
- 教你50招提升ASP.NET性能(二十六):对于开发人员的数据库性能技巧
Database Performance Tips for Developers对于开发人员的数据库性能技巧 As a developer you may or may not need to go ...
- 教你50招提升ASP.NET性能(十六):把问题仍给硬件而不是开发人员
(27)Throw hardware at the problem, not developers 招数27: 把问题仍给硬件而不是开发人员 As developers, we often want ...
- 教你50招提升ASP.NET性能(十一):避免在调试模式下运行网站
(17)Avoid running sites in debug mode 招数17: 避免在调试模式下运行网站 When it comes to ASP.NET, one of the most c ...
- 教你50招提升ASP.NET性能(七):总是在服务器端执行验证
(13)Always perform validation on the server as well 招数13: 总是在服务器端执行验证 This isn’t exactly a performan ...
- 教你50招提升ASP.NET性能(二):移除不用的视图引擎
(2)Remove unused View Engines 招数2: 移除不用的视图引擎 If you're an ASP.NET MVC developer, you might not know ...
- 教你50招提升ASP.NET性能(二十四):ORM小窍门
ORM TipsORM小窍门 More and more people are using Object to Relational Mapping (ORM) tools to jump the d ...
- 教你50招提升ASP.NET性能(二十一):避免使用会话状态
(39)Avoid using session state 招数39: 避免使用会话状态 Where possible, you should try and avoid using session ...
- 教你50招提升ASP.NET性能(二十):7条便利的ViewState技巧
(32)Seven handy ViewState tips 招数32: 7条便利的ViewState技巧 Every time I have to deal with a classic ASP.N ...
- 教你50招提升ASP.NET性能(十九):静态集合
(30)Static collections 招数30: 静态集合 If a collection is static, make sure it only contains the objects ...
随机推荐
- 14条建议,使你的IT职业生涯更上一层楼
摘要:升值为企业IT部门的领导者,是大部分IT技术人员职业生涯的最终追求.但从一般大众中脱颖而出,并非易事.仅仅把本职工作干好远远不够,还需要IT技术人员展示出投身于技术发展的奉献精神及伴随技术发展而 ...
- Android学习Service中遇到的问题
今天学习service,然后遇到了一个force close,log中存在这个一句话: 05-23 14:13:26.408: E/AndroidRuntime(17616): android.con ...
- sizeof(数组)
这里就不讨论一般的数组长度计算了,只说明一下任何数据到了函数的形参中都将退化为指针,所以计算大小的时候,也是计算的指针的大小 直接上代码了 // class sizeof测试.cpp : 定义控制台应 ...
- bzoj3572
通过这题我知道了一个鬼故事,trunc(ln(128)/ln(2))=6……以后不敢轻易这么写了 好了言归正传,这题明显的构建虚树,但构建虚树后怎么树形dp呢? 由于虚树上的点不仅是议事会还有可能是议 ...
- SCOI2009windy数
数位DP,还不怎么会…… 其中calc函数的计算分为三部分: 第一部分:统计最高位为0的情况,或者说不足最高位位数的数的个数 第二部分:统计最高位为1到a[len]-1的情况,直接调用数组即可 第三部 ...
- SGU 185 Two shortest ★(最短路+网络流)
[题意]给出一个图,求 1 -> n的2条 没有重边的最短路. 真◆神题--卡内存卡得我一脸血= =-- [思路] 一开始我的想法是两遍Dijkstra做一次删一次边不就行了么你们还又Dijks ...
- ♫【jQuery插件】图片放大镜
JQZoom
- Spring中使用quartz插件实现定时任务
第一步:导入架包 *spring3.2.3版本的架包将spring的各个功能模块给分开了,我们必须将Spring必须依赖的包导入上去 第二步:编写配置文件 <?xml version=" ...
- 【 D3.js 高级系列 — 5.0 】 颜色
颜色是作图不可少的概念,常用的标准有 RGB 和 HSL,D3 提供了创建颜色对象的方法,能够相互转换和插值. RGB色彩模式是通过对红(Red).绿(Green).蓝(Blue)三个颜色通道相互叠加 ...
- Java [leetcode 27]Remove Element
题目描述: Given an array and a value, remove all instances of that value in place and return the new len ...