我使用 IIS 6 和 IIS 7 作为 Web 服务器。
运行Google page speed online后,它指出我应该:在静态资源的HTTP header 中设置到期日期或最长期限,指示浏览器加载以前下载的资源从本地磁盘而不是通过网络。
它列出了很多简单的图像、我的javascript文件和样式表。
如何为这些静态文件设置到期日期?我以为这是浏览器自动完成的?
最佳答案
利用浏览器缓存:
Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.
http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching
在静态资源的 HTTP header 中设置到期日期或最长期限
打开 IIS 管理器 -> 单击您的站点 -> 单击主页中的 HTTP 响应 header -> 单击操作面板上的设置通用 header -> 检查 Web 内容过期 -> 设置 7 天后(按照中的建议)页面速度分析“指定以下资源至少在未来一周内到期”
http://technet.microsoft.com/en-us/library/cc770661%28WS.10%29.aspx
关于caching - 如何在 IIS 中设置静态资源的 HTTP header 中的到期日期或最长期限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5562898/