【发布时间】:2011-01-02 15:18:24
【问题描述】:
我不想在任何地方缓存我的 aspx 页面。出于某种原因,IE 会忽略从我的母版页设置的元标记
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
我正在尝试查看是否可以将我的 Http 响应标头设置为“Cache-Control”-“no-cache”。设置类似
HttpContext.Current.Response.Headers.Add("Cache-Control", "no-cache");
HttpContext.Current.Response.Headers.Add("Exipres", DateTime.Now.AddDays(-1).ToShortDateString());
在每一页都会很痛苦。我在想是否无论如何我们可以在 IIS7 中设置它(将此标头添加到 aspx 页面,但不是图像/css/js)。有可能吗?
编辑:根据http://technet.microsoft.com/en-us/library/cc753133%28WS.10%29.aspx 中的建议,添加自定义 http 响应标头会将标头添加到包括 js、css、图像在内的所有文件中。所以在这里添加“Cache-Control”、“no-cache”也不起作用
Edit2:我正在考虑添加一个 httpmodule 。类似于http://blogs.technet.com/stefan_gossner/archive/2008/03/12/iis-7-how-to-send-a-custom-server-http-header.aspx 的东西。有什么建议吗?
【问题讨论】:
标签: asp.net iis caching http-headers