【发布时间】:2013-03-26 18:39:05
【问题描述】:
在我的 .NET 代码中,我有一个处理 Http 请求的自定义处理程序,并且在 ProcessRequest 方法中调用一个自定义 HttpModule 来设置 Http 缓存标头。
HttpModule 使用以下代码在 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 中的网络服务器部分:
<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>
我尝试添加此处提到的 SetSlidingExpiration Cache.SetMaxAge not working under IIS, works fine under VS Dev Srv,但没有帮助。
【问题讨论】:
标签: iis http-headers iis-7.5 cache-control integrated-pipeline-mode