是否有 <meta>标签关闭所有浏览器中的缓存? [英] Is there a <meta> tag to turn off caching in all browsers?

查看:25
本文介绍了是否有 <meta>标签关闭所有浏览器中的缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到,当您无权访问 Web 服务器的标头时,您可以使用以下方法关闭缓存:

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

解决方案

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

有关正确信息,请参阅页面顶部列出的重复项!

在此处查看答案:如何跨所有浏览器控制网页缓存?

<小时>

IE9 及之前版本

不要盲目复制粘贴!

<块引用>

该列表只是不同技术的示例,不适用于直接插入.如果复制,第二个将覆盖第一个和由于 http-equiv,第四个会覆盖第三个W3C 验证器声明和失败.最多,一个人可以有每个 http-equiv 声明之一;编译指示、缓存控制和到期.当使用现代的最新浏览器时,这些已经完全过时了.无论如何,在IE9之后.Chrome 和 Firefox 特别不能像您期望的那样使用这些,如果有的话.

<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"/>

实际上根本不要使用这些!

<块引用>

缓存头在元元素中是不可靠的;一方面,网站和用户之间的任何网络代理都将完全忽略他们.您应该始终使用真实的 HTTP 标头作为标头,例如缓存控制和编译指示.

I read that when you don't have access to the web server's headers you can turn off the cache using:

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

But I also read that this doesn't work in some versions of IE. Are there any set of <meta> tags that will turn off cache in all browsers?

解决方案

For modern web browsers (After IE9)

See the Duplicate listed at the top of the page for correct information!

See answer here: How to control web page caching, across all browsers?


For IE9 and before

Do not blindly copy paste this!

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" />

Actually do not use these at all!

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.

这篇关于是否有 &lt;meta&gt;标签关闭所有浏览器中的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆