教你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 ...
随机推荐
- CGI/FASTCGI/ISAPI区别
一 CGI原理及其性能 1) CGI概念CGI即通用网关接口(Common Gateway Interface),它是一段程序,运行在服务器上,提供同客户端HTML页面的交互,通俗的讲CGI就象是一座 ...
- sublime text格式化插件
sublime text 软件其实是自带格式化插件的,但是它默认的格式化插件,不太好用,且没有快捷键(虽然自己可以设置). 其默认的格式化是在 Edit -> Line -> Re ...
- freemarker得到数组的长度
取得list的长度:${fields?size}.用?size不是用?length,代码如下所示: <#list properties as item> <#assign layer ...
- 解决IIS6.0不能下载EXE文件之妙方!
2003系统 IIS6建站 有EXE文件下载 但老是不让下载.当我把站删除再建后可以下载,但过一会又不让下载了.另,MIME里有EXE这项!请问这是为什么?应如何处理? 答案: win2003服务器允 ...
- apache开源项目--ApacheDS
ApacheDS (Apache Directory Server)的核心是目录服务,可以保存数据,并对不同类型的数据进行搜索操作.协议的实现在目录服务器顶层工作,提供与数据存储.搜索和检索有关的 I ...
- 逻辑回归损失函数(cost function)
逻辑回归模型预估的是样本属于某个分类的概率,其损失函数(Cost Function)可以像线型回归那样,以均方差来表示:也可以用对数.概率等方法.损失函数本质上是衡量”模型预估值“到“实际值”的距离, ...
- 【转】Android自定义View的实现方法,带你一步步深入了解View(四)
原文网址: 转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/17357967 不知不觉中,带你一步步深入了解View系列的文章已经写到 ...
- Diamond
Diamond主要提供持久配置的发布和订阅服务,最大特点是结构简单,稳定可靠.Diamond的主要使用场景是用来进行动态数据库切换与扩容,进行一些业务系统运行时开关配置的推送.Diamond产品专注于 ...
- Hdu oj 5522 Numbers 之解题报告
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABCwAAAL7CAIAAAC5m4NqAAAgAElEQVR4nOy9e7QdVZUvXH+RMcJVdJ
- Express细节探究(1)——app.use(express.static)
express相信是很多人用nodejs搭建服务器的首选框架,相关教程有很多,也教会了大家来如何使用.如果你想更深的了解他的细节,不妨和我一起来研究一下. 先来看一个每个人都用到的方法app.use( ...