我有一个在VS10 Dev服务器下运行的ASP.NET网站。我希望某些静态内容文件可以用最长时间的缓存指令提供,但似乎无法使其工作。ASP.NET静态内容配置选项不起作用
我有这个在我的web.config:
<system.webServer>
<caching enabled="true" enableKernelCache="true">
</caching>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
而且在内容文件夹中缓存
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge"
cacheControlMaxAge="30.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
但它也不管用,它总是与服务Cache-Control:private
那么,是否支持staticContent配置?如果没有,任何解决方法?如果是这样,我错过了什么?
页眉我在所有的请求得到:
Server: ASP.NET Development Server/10.0.0.0
Date: Thu, 23 Feb 2012 20:47:56 GMT
Cache-Control: private
Content-Type: application/octet-stream
Content-Length: 1043
Connection: Close
您是否在web.config中有
2012-02-23 22:59:40
你看过这个吗? http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache – Aristos 2012-02-23 23:07:47
也许你在你的程序中的其他地方设置标题(例如global.asax) – Aristos 2012-02-23 23:09:31