0
在我的.NET代码,我有处理的HTTP请求的自定义处理程序,并在processRequest方法调用一个自定义的HttpModule设置HTTP缓存头。IIS 7.5的力量HTTP头CacheControl设置私人
的HTTP模块设置在PreSendRequestHeaders方法的标题用下面的代码
HttpCachePolicy cache = response.Cache;
if (cache != null)
{
cache.SetCacheability(HttpCacheability.Public);
cache.SetMaxAge(TimeSpan.FromSeconds(varnishDuration));
response.AppendHeader("Edge-control", String.Concat("!no-store, max-age=", akamaiDuration, "s dca=noop"));
}
在IIS 7.5,随着集成模式的池,CacheControl被迫私人。 这里是我的了:
curl -IXGET -H "Host:myHostName" "http://myServer/mypage"
HTTP/1.1 200 OK
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Edge-control: !no-store, max-age=300s dca=noop
[...]
我不明白为什么IIS改变CacheControl设置专用。
这里是我的web.config我的web服务器部分:
<pre>
<system.webServer>
<handlers accessPolicy="Read, Script">
<add name="OxygenHandler" verb="*" path="*" type="com.eurosport.oxygen.server.modules.OxygenHandlerFactory, OxygenServerModules" />
</handlers>
<modules runAllManagedModulesForAllRequests="true">
<add name="WebServiceCachingModule" type="com.eurosport.toolkit.WebServiceCachingModule, Eurosport.Toolkit" />
</modules>
</system.webServer>
</pre>
我想这里Cache.SetMaxAge not working under IIS, works fine under VS Dev Srv提到添加SetSlidingExpiration,但它并没有帮助。