Joe*_*Fan 2 asp.net iis-7 caching
我看到一些使用浏览器缓存的静态页面的问题,这是不希望的。为了防止缓存,我正在设置
<clientCache cacheControlMode="DisableCache" />
Run Code Online (Sandbox Code Playgroud)
<location>在 web.config的相关标签中
如果我在 Firebug 中打开页面(在Net选项卡中),我会看到 Response 标头 Cache-Control: no-cache是正确的,但 Response 的状态是304 Not Modified!这不是矛盾吗?我怎样才能让它停止缓存(即总是发送一个 200 的内容)?
根据 RFC ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1 , section 14.9.1) Cache-control: no-cache 告诉浏览器不要使用缓存的内容无需先与服务器重新验证。这就是为什么您会看到 304 的原因。我想你正在寻找Cache-Control: no-store.
我不确定您是否可以通过配置文件发送 no-store。但是,您可以在响应中显式设置标头:
Response.Cache.SetNoStore();
Run Code Online (Sandbox Code Playgroud)
编辑:(由OP)
我要找的是:
<clientCache cacheControlCustom="no-store" />
Run Code Online (Sandbox Code Playgroud)