如何指定 HTTP 过期标头?(ASP.NET MVC+IIS) [英] How to specify HTTP expiration header? (ASP.NET MVC+IIS)
本文介绍了如何指定 HTTP 过期标头?(ASP.NET MVC+IIS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在我的 ASP.NET MVC 应用程序中使用了输出缓存.
I am already using output caching in my ASP.NET MVC application.
Page speed 告诉我在响应头.
我知道 Response 对象包含一些控制缓存过期的属性.我知道这些属性可用于控制 HTTP 缓存以获取我从我的代码提供的响应:
I know that the Response object contains some properties that control cache expiration. I know that these properties can be used to control HTTP caching for response that I am serving from my code:
Response.Expires
Response.ExpiresAbsolute
Response.CacheControl
或者
Response.AddHeader("Expires", "Thu, 01 Dec 1994 16:00:00 GMT");
问题是 如何为自动提供的资源设置 Expires 标头,例如图片、css之类的?
推荐答案
找到了:
我需要为静态内容指定客户端缓存(在 web.config 中).
I need to specify client cache for static content (in web.config).
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public"
cacheControlMaxAge="12:00:00" cacheControlMode="UseMaxAge" />
</staticContent>
</system.webServer>
</configuration>
来自 http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache
这篇关于如何指定 HTTP 过期标头?(ASP.NET MVC+IIS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文