IIS 7.0 - IIS 向缓存控制添加“私有”,它来自哪里

Bri*_*rds 5 iis-7 web-config browser-cache http-headers

因为我们保护 .PDF 文件免受匿名用户的侵害,所以我们有一个自定义处理程序,所以我们有一个条目

我们还对 http 标头进行了更改,以通过 IIS 7 管理添加“cache-control: no-cache,no-store”,这会在 system.webserver 元素下创建 web.config 条目,如下所示:

<httpProtocol>

  <customHeaders>
    <clear />
    <add name="cache-control" value="no-cache,no-store" />
  </customHeaders>

</httpProtocol>
Run Code Online (Sandbox Code Playgroud)

当我在 burpsuite 会话中查看响应标头时,我看到 .aspx 页面:cache-control: no-store,no-cache,no-store

但对于 PDF 页面:

缓存控制:私有,无缓存,无存储

我的目标是让一切都变成“无缓存,无存储”。我不确定我错过了什么。web.config 中没有其他缓存设置。请告知如何从 PDF 页面中删除“私人”以及如何从所有其他页面中删除额外的无商店。其他通过 System.Web.StaticFileHandler 的静态页面,它们也有“no-store,no-cache,no-store”。

Arm*_*nco 0

我无法告诉你为什么 IIS 7 向缓存控制添加“私有”,但我可以向你展示如何在我自己的基于 ASHX 的直通代理中摆脱它(请参阅原始帖子下面的第 1 条评论) 。

public class proxy : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        HttpResponse response = context.Response;

        // Remove the 'private' string value from the response.CacheControl member
        if (response.CacheControl == "private")
        {
            response.CacheControl = String.Empty;
        }

        // Do other stuff
    }
}
Run Code Online (Sandbox Code Playgroud)

如果您在 Visual Studio 中使用内置的 Cassini Web 开发服务器,这将不起作用。为了搞乱标头,您需要在开发环境中切换到成熟的 IIS Web 服务器。