使用 ASP.NET 和 IIS 7.5 控制浏览器缓存
Google PageSpeed 建议我的网站优先考虑以下内容。
以下可缓存资源的新鲜生命周期较短。 指定以下内容至少在未来一周内到期 资源:
并建议进一步阅读。
我使用的是 Windows Server 2008 r2、.net Framework 4.0、asp.net 和 IIS 7.5。如何延长某些文件的缓存有效期?
我尝试了以下 web.config,但它不起作用。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<sessionState mode="Off" />
</system.web>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
Google PageSpeed suggests the following this for my website as a high priority.
The following cacheable resources have a short freshness lifetime.
Specify an expiry of at least one week in the future for the following
resources:
And suggests further reading.
I am using Windows Server 2008 r2, .net framework 4.0, asp.net and IIS 7.5. How can I increase the cache expiry for some files?
I've tried the following web.config, but it doesn't work.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<sessionState mode="Off" />
</system.web>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定这不起作用吗?我只是用一张图像敲出了一个简单的页面作为测试。准确添加您的配置部分并签入 firebug。
这是标题。
对我来说看起来不错。
Are you sure this is not working. I just knocked up a simple page with a single image as a test. Added your config section exactly and checked in firebug.
Here are the headers.
Looks ok to me.