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

发布于 2024-08-03 01:19:09 字数 193 浏览 13 评论 0原文

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

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

但我还读到,这在某些版本的 IE 中不起作用。是否有任何

集合?将关闭所有浏览器中的缓存的标签?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

深爱成瘾 2024-08-10 01:19:09

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

请参阅页面顶部列出的重复项以获取正确信息!

请参阅此处的答案: 如何跨所有浏览器控制网页缓存?


对于IE9及之前版本

请勿盲目复制粘贴!

该列表只是不同技术的示例,不适合直接使用
插入。如果复制,第二个将覆盖第一个
由于 http-equiv,第四个会覆盖第三个
声明 AND 通过 W3C 验证器失败。最多一个人可以拥有
每个 http-equiv 声明之一;编译指示、缓存控制和
过期。当使用现代的最新浏览器时,这些已经完全过时了。
反正IE9之后。 Chrome 和 Firefox 根本无法像您所期望的那样使用这些工具(如果有的话)。

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

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

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

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.

长不大的小祸害 2024-08-10 01:19:09

根据独立安全评估者的伟大 全行业对缓存控制的误解案例研究,只有Cache-Control: no-store被Chrome、Firefox和IE识别。 IE 可以识别其他控件,但 Chrome 和 Firefox 不能。

According to Independent Security Evaluators' great case study on the industry-wide misunderstanding of controlling caches, only Cache-Control: no-store is recognized by Chrome, Firefox, and IE. IE recognizes other controls, but Chrome and Firefox do not.

心房敞 2024-08-10 01:19:09

它在 IE5 中不起作用,但这不是一个大问题。

然而,缓存 headers 在元元素中是不可靠的;其一,网站和用户之间的任何网络代理都将完全忽略它们。您应该始终对 Cache-Control 和 Pragma 等标头使用真实的 HTTP 标头。

It doesn't work in IE5, but that's not a big issue.

However, cacheing 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.

无可置疑 2024-08-10 01:19:09

pragma 是你最好的选择:

<meta http-equiv="Pragma" content="no-cache">

pragma is your best bet:

<meta http-equiv="Pragma" content="no-cache">
围归者 2024-08-10 01:19:09

当重复相同的服务调用(长轮询)时,我注意到服务调用存在一些缓存问题。添加元数据没有帮助。一种解决方案是传递时间戳以确保ie认为这是不同的http服务请求。这对我有用,因此添加服务器端脚本代码片段来自动更新此标签不会有什么坏处:

I noticed some caching issues with service calls when repeating the same service call (long polling). Adding metadata didn't help. One solution is to pass a timestamp to ensure ie thinks it's a different http service request. That worked for me, so adding a server side scripting code snippet to automatically update this tag wouldn't hurt:

<meta http-equiv="expires" content="timestamp">

沫离伤花 2024-08-10 01:19:09

尝试使用

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">

Try using

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文