html - 是否有一个 <meta> 标签来关闭所有浏览器中的缓存?

标签 html internet-explorer firefox caching asp.net-web-api

我了解到,当您无法访问 Web 服务器的 header 时,您可以使用以下方法关闭缓存:

<meta http-equiv="Cache-Control" content="no-store" />

但我也读到这在某些版本的 IE 中不起作用。是否有任何一组 <meta> 标签可以关闭所有浏览器中的缓存?

最佳答案

适用于现代网络浏览器(IE9 之后)

有关正确信息,请参阅页面顶部列出的副本!

在此处查看答案:How to control web page caching, across all browsers?


适用于 IE9 及之前

不要盲目复制粘贴!

The list is just examples of different techniques, it's not for direct insertion. If copied, the second would overwrite the first and the fourth would overwrite the third because of the http-equiv declarations AND fail with the W3C validator. At most, one could have one of each http-equiv declarations; pragma, cache-control and expires. These are completely outdated when using modern up to date browsers. After IE9 anyway. Chrome and Firefox specifically does not work with these as you would expect, if at all.

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

其实根本不用这些!

Caching headers are unreliable in meta elements; for one, any web proxies between the site and the user will completely ignore them. You should always use a real HTTP header for headers such as Cache-Control and Pragma.

关于html - 是否有一个 &lt;meta&gt; 标签来关闭所有浏览器中的缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1341089/

相关文章:

javascript - document.getElementById 无法正常工作

javascript - 替换损坏的图像并使用 javascript 调整错误图像的大小

internet-explorer - 文本溢出 : ellipsis in IE

Firefox 后退按钮与 iframe

javascript - 背景位置图像叠加(适用于 IE,不适用于 Mozilla/Chrome/Safari)

javascript - 使用 javascript 的一行的 bresenham 算法

javascript - 使用 jquery 选择选项在 IE 中不起作用?

javascript - Internet Explorer Javascript 图像问题

javascript - 检测何时使用 Firebug(或任何其他网络调试器)进行调试

html - 使 div 不可扩展