- 浏览: 851120 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
zjhzwx1212:
为什么用threadLocal后,输出值是从20开始的,而定义 ...
j2ee的线程安全--threadlocal -
aeoluspu:
不错 mysql 测试部分感觉不详细
用sysbench(或者super-smack)测试mysql性能 -
nanPrivate:
有没有例子,只理论,实践起来还是不会啊
JMS可靠消息传送 -
lwclover:
一个网络工程师 装什么b
postfix 如何删除队列中的邮件 -
maimode:
我也欠缺不少啊
理想的计算机科学知识体系
Use URLs consistently
Browsers cache content based on the URL. When URL changes, browser fetches a new version from origin server. URL can be changed by changing the query string parameters. For example, “/default.aspx” is cached on the browser. If you request “/default.aspx?123” it will fetch new content from server. Response from the new URL can also be cached in browser if you return proper caching headers. In that case, changing the query parameter to something else like “/default.aspx?456” will return new content from server. So, you need to make sure you use URL consistently everywhere when you want to get cached response. From homepage, if you have requested a file with URL “/welcome.gif”, make sure from another page you request the same file using the same URL. One common mistake is to sometimes omit the “www” subdomain from the url. www.pageflakes.com/default.aspx is not same as pageflakes.com/default.aspx. Both will be cached separately.
Cache static content for longer period
Static files can be cached for longer period like one month. If you are thinking that you should cache for couple of days so that when you change the file, users will pick it up sooner, you’re mistaken. If you update a file which was cached by Expires header, new users will immediately get the new file while old users will see the old content until it expires on their browser. So, as long as you are using Expires header to cache static files, you should use as high value as possible.
For example, if you have set expires header to cache a file for three days, one user will get the file today and store it in cache for next three days. Another user will get the file tomorrow and cache it for three days after tomorrow. If you change the file on the day after tomorrow, the first user will see it on fourth day and the second user will see it on fifth day. So, different users will see different versions of the file. As a result, it does not help setting a lower value assuming all users will pick up the latest file soon. You will have to change the url of the file in order to ensure everyone gets the exact same file immediately.
You can setup Expires header from static files from IIS Manager. You’ll learn how to do it in later section.
Use cache friendly folder structure
Store cached content under a common folder. For example, store all images of your site under the “/static” folder instead of storing images separately under different subfolders. This will help you use consistent URL throughout the site because from anywhere you can use “/static/images/somefile.gif”. Later on, we will learn it’s easier to move to a Content Delivery Network when you have static cacheable files under a common root folder.
Reuse common graphics files
Sometimes we put common graphics files under several virtual directories so that we can write smaller paths. For example, say you have indicator.gif in root folder, some subfolders and under CSS folder. You did it because you need not worry about paths from different places and you could just use the file name as relative URL. This does not help in caching. Each copy of the file is cached in browser separately. So, you should collect all graphics files in the whole solution and put them under the same root “static” folder after eliminating duplicates and use the same URL from all the pages and CSS files.
Change file name when you want to expire cache
When you want a static file to be changed, don’t just update the file because it’s already cached in user’s browser. You need to change the file name and update all references everywhere so that browser downloads the new file. You can also store the file names in database or configuration files and use data binding to generate the URL dynamically. This way you can change the URL from one place and have the whole site receive the change immediately.
Use a version number while accessing static files
If you do not want to clutter your static folder with multiple copies of the same file, you can use query string to differentiate versions of same file. For example, a GIF can be accessed with a dummy query string like “/static/images/indicator.gif?v=1”. When you change the indicator.gif, you can overwrite the same file and then update all references to the file to “/static/images/indicator.gif?v=2”. This way you can keep changing the same file again and again and just update the references to access the graphics using the new version number.
Store cacheable files in a different domain
It’s always a good idea to put static contents in a different domain. First of all, browser can open another two concurrent connections to download the static files. Another benefit is that you don’t need to send the cookies to the static files. When you put the static files on the same domain as your web application, browser sends all the ASP.NET cookies and all other cookies that your web application is producing. This makes the request headers be unnecessarily large and waste bandwidth. You don’t need to send these cookies to access the static files. So, if you put the static files in a different domain, those cookies will not be sent. For example, put your static files in www.staticcontent.com domain while your website is running on www.dropthings.com. The other domain does not need to be a completely different web site. It can just be an alias and share the same web application path.
SSL is not cached, so minimize SSL use
Any content that is served over SSL is not cached. So, you need to put static content outside SSL. Moreover, you should try limiting SSL to only secure pages like Login page or Payment page. Rest of the site should be outside SSL over regular HTTP. SSL encrypts request and response and thus puts extra load on server. Encrypted content is also larger than the original content and thus takes more bandwidth.
HTTP POST requests are never cached
Cache only happens for HTTP GET requests. HTTP POST requests are never cached. So, any kind of AJAX call you want to make cacheable, it needs to be HTTP GET enabled.
Generate Content-Length response header
When you are dynamically serving content via web service calls or HTTP handlers, make sure you emit Content-Length header. Browsers have several optimizations for downloading contents faster when it knows how many bytes to download from the response by looking at the Content-Length header. Browsers can use persisted connections more effectively when this header is present. This saves browser from opening a new connection for each request. When there’s no Content-Length header, browser doesn’t know how many bytes it’s going to receive from the server and thus keeps the connection open as long as it gets bytes delivered from the server until the connection closes. So, you miss the benefit of Persisted Connections that can greatly reduce download time of several small files like css, javascripts, and images.
How to configure static content caching in IIS
In IIS Manager, Web site properties dialog box has “HTTP Headers” tab where you can define Expires header for all requests that IIS handles. There you can define whether to expire content immediately or expire after certain number of days or on a specific date. The second option (Expire after) uses sliding expiration, not absolute expiration. This is very useful because it works per request. Whenever someone requests a static file, IIS will calculate the expiration date based on the number of days/months from the Expire after.
For dynamic pages that are served by ASP.NET, a handler can modify the expires header and override IIS default setting.
发表评论
-
Improving performance and scalability with DDD
2010-09-19 14:57 1074http://gojko.net/2009/06/23/imp ... -
Java EE meets Web 2.0
2010-09-19 14:56 2511http://www.ibm.com/developerwor ... -
最全面的Hibernate 性能优化技巧
2010-08-19 16:28 1188http://www.duka ... -
必备的 Java 参考资源列表
2010-03-16 11:42 1426Java™ 平台不久将迎来 ... -
CWE/SANS发布2010年25个最危险的编程错误
2010-02-26 09:05 1247http://www.infoq.com/cn/news/20 ... -
一个程序员的多年珍藏(Java&Linux)
2010-01-15 17:25 5443http://jythoner.iteye.com/blog/ ... -
Java 推荐读物与源代码阅读
2010-01-15 17:24 1138http://jythoner.iteye.com/blog/ ... -
A Spring Security ACL tutorial for PostgreSQL
2010-01-01 22:48 1542http://server.denksoft.com/word ... -
ddd using jpa
2009-12-28 10:00 1084http://www.iteye.com/topic/6540 ... -
java的ddd框架
2009-12-28 09:43 2718SpringXT是Spring框架的一个扩展用于开发riche ... -
hibernate session cache tips
2009-12-27 22:13 10061、只有当通过主键load或者get时,hibernate才不 ... -
事物tips
2009-12-27 20:27 9751、只读标志只在事务启动时应用。不启动任何事务,则只读标志被忽 ... -
常用正则表达式
2009-12-24 10:11 1022Email : /^\w+([-+.]\w+)*@\w+([- ... -
hibernate batch insert 和id策略
2009-11-17 10:40 1153在id生成策略为native的情况下,batch insert ... -
两个好用的java反编译工具
2009-11-09 09:54 900jad jd-gui -
Design Patterns in Dynamic Programming
2009-11-07 23:04 1070http://norvig.com/design-patter ... -
几个好用的开源工具
2009-11-02 14:20 1169DBDesigner4 一款开源的数据库设计、建模、维 ... -
持续集成的极好例子
2009-10-28 09:56 1959http://www.iteye.com/topic/4993 ... -
fix tomcat memory settings
2009-10-27 16:10 968-Dorg.apache.jasper.runtime.Bod ... -
CI和maven私服
2009-10-22 18:56 1078Nexus quickbuild hudson
相关推荐
Analysis of local elastic shear buckling of trapezoidal corrugated steel webs
标题与描述:“霍尼韦尔WEBS培训资料” 知识点概览: 1. **霍尼韦尔WEBS系统介绍**:霍尼韦尔WEBS(Web Enabled Building Solutions)系统是一种先进的楼宇自动化解决方案,它集成了楼宇管理系统(BMS)、安防、...
Web系统安装手册(WEBs-AX™ Configuration & Installation Guide)是一份详细介绍基于NiagaraAX®框架的WEBs-AX™系统的安装与配置的文档。该手册的目的是为IT部门的最终用户,特别是那些对WEBs-AX™软件的基础操作...
Webs以其小巧的体积、高效的性能以及易于移植性而受到青睐。与Boa服务器相比,Webs可能提供更简洁的配置和更高的定制化能力,因此在某些场景下可能更适合开发者使用。 移植Webs到新的嵌入式平台时,主要涉及以下几...
【霍尼韦尔WEBs培训资料详解】 霍尼韦尔WEBs系统,全称为Web Enterprise Suite,是一款由霍尼韦尔公司开发的先进的自动化控制系统,主要用于实现工业环境中的过程控制、监控以及数据管理。该系统以其高效、稳定、...
霍尼韦尔WEBS系统是霍尼韦尔公司推出的一款先进的过程控制系统,它集成了监控、操作、数据采集和分析等功能,广泛应用于工业自动化领域。这份"霍尼韦尔WEBS培训资料第二部分(全)"是深入理解并熟练掌握该系统的重要...
Honeywell WEBs楼宇自控系统是霍尼韦尔公司推出的先进的楼宇管理系统,其技术核心是Niagara体系架构,这一开创性架构指导下的WEBs系列产品,适用于楼宇控制系统、工业控制领域以及能源管理市场。Honeywell WEBs系统...
Along the way you’ll gain vital concepts as you follow instructions for making Web of Things devices. By the end, you’ll have the practical skills you need to implement your own web-connected ...
《WEBS编程手册》是一本非常适合初学者的教程,它主要涵盖了软件基础知识、软件使用注意事项以及项目编程流程等核心内容,旨在帮助用户更好地理解和掌握WEBS编程技术。 首先,我们来了解一下软件基础知识部分: 1....
Honeywell WEBs楼宇自控系统是全球领先的建筑自动化解决方案之一,主要应用于商业、工业及公共设施等大型建筑物的环境控制。该系统以其高效、可靠和易于管理的特点,实现了对建筑内部空调、照明、安全、能源管理等多...
霍尼韦尔WEBs楼宇自控系统是一款先进的自动化控制系统,专为现代建筑的环境控制和能源管理设计。这个系统能够整合建筑物内的各种设备,如暖通空调(HVAC)、照明、安全、消防等,实现全面的监控和智能管理。下面将...
标题 "webs218.tar.gz" 提供的信息表明这是一个包含 Web 服务相关资源的压缩文件,格式为 .tar.gz,这种格式在 Linux 和类 Unix 系统中常见,用于打包和压缩多个文件或目录。".tar" 部分表示这是一组通过 tar 命令...
"霍尼韦尔WEBs专项方案模板" 霍尼韦尔WEBs专项方案模板是一种楼宇自控管理系统的解决方案,旨在提供一个全面的楼宇管理系统,涵盖楼宇的各个方面,如空调、照明、电梯、变配电、给排水等系统。该模板提供了一个详细...
webs 2022.2.1
《Goahead2.5详解》是一份深入剖析Goahead服务器软件2.5版本的文档,旨在帮助读者理解和掌握这一轻量级嵌入式Web服务器的工作原理、配置与应用。... Goahead2.5的核心知识点包括以下几个方面: 1. **Goahead架构**:...
【标题】"Web_webs_" 暗示了这个压缩包可能包含与Web开发相关的资源,特别是关于构建网站或Web应用程序的内容。"example sketch arduino" 提示我们这里可能有一个Arduino项目的示例,该示例可能涉及到Web交互或数据...
【Java_webs.zip】是一个包含Java Web开发的项目,主要用于构建一个商品管理平台,它集成了后台管理员管理和用户购物功能,并且支持在线支付。这个项目是使用Java编程语言,特别是Servlet和JSP(JavaServer Pages)...
标题 "Program to open webs togethor" 暗示我们需要讨论的是一个用于同时打开多个网页的应用程序或脚本。在互联网使用中,有时我们需要一次性打开一组相关网站,例如进行研究、工作协作或数据分析。这样的程序可以...