小编Rob*_*ith的帖子

使用新值替换使用 web.config 的缓存控制

我有一个 asp.net 网站,默认情况下在标头中发送以下缓存:

缓存控制:私有

我想将 Cache-Control 更改为:

no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
Run Code Online (Sandbox Code Playgroud)

但是,当我将以下内容添加到网络配置时:

<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="Cache-Control" />
<remove name="Pragma" />
<remove name="Expires" />
<add name="Cache-Control" value="no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0" />
<add name="Pragma" value="no-cache" />
<add name="Expires" value="0" />
</customHeaders>
</httpProtocol>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)

它仍然将 Cache-Control 标头中的“私有”字符串发送到客户端:

Cache-Control
private,no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
Run Code Online (Sandbox Code Playgroud)

您可以注意到它甚至没有在“private”后面放置空格,它仍然将其添加到响应的开头。如何使用 web.config 从 Cache-Control 中删除“私有”?先谢谢了。

asp.net iis web-config asp.net-mvc-4

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

asp.net ×1

asp.net-mvc-4 ×1

iis ×1

web-config ×1