我使用了 YSlow Firefox 附加组件,它返回了以下结果:
添加过期 header 的 F 级
有 8 个没有远期到期日期的静态组件。
* (no expires) http://localhost:63808/WebSite/css/Global.css?...
* (no expires) http://localhost:63808/WebSite/css/BemVindo.css?...
* (no expires) http://localhost:63808/WebSite/js/Global.js?...
* (no expires) http://localhost:63808/WebSite/js/BemVindo.js?...
* (no expires) http://www.maplist.com.br/img/faixa_verde.png
* (no expires) http://www.maplist.com.br/img/logo_home.png
* (no expires) http://www.maplist.com.br/img/wait_bar.gif
* (2010/1/23) http://localhost:63808/WebSite/favicon.ico
我使用 HttpHandler 组件解决了这个问题:
www.codeproject.com/KB/aspnet/CssAndJavaScriptOptimizer.aspx
有没有更简单的方法来解决这个问题?也许在 global.asax 中?
顺便说一句,我在我的页面中使用了这个元数据:
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="PUBLIC">
<META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2010 11:12:01 GMT">
最佳答案
您必须更改这些页面的 Expires:
header ,使它们在遥远的将来过期,从而允许用户浏览器缓存它们。
您可以使用 mod_expires在 apache 中,或 this technique . Here是一篇解释如何使用 IIS 执行此操作的文章。
关于http - 添加过期 header 的 F 级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2120762/