使用<meta>标签关闭所有浏览器的缓存? [重复]

本文翻译自:Using tags to turn off caching in all browsers? [duplicate]

This question already has an answer here: 这个问题在这里已有答案:

I read that when you don't have access to the web server's headers you can turn off the cache using: 我读到,当您无法访问Web服务器的标头时,您可以使用以下命令关闭缓存:

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

But I also read that this doesn't work in some versions of IE. 但我也读到这在某些版本的IE中不起作用。 Are there any set of <meta> tags that will turn off cache in all browsers? 是否有任何<meta>标签可以关闭所有浏览器中的缓存?


#1楼

参考:https://stackoom.com/question/5csT/使用-meta-标签关闭所有浏览器的缓存-重复


#2楼

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. 一种解决方案是传递timestamp以确保ie认为它是不同的http服务请求。 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">


#3楼

Try using 尝试使用

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

#4楼

pragma是你最好的选择:

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

#5楼

It doesn't work in IE5, but that's not a big issue. 它在IE5中不起作用,但这不是一个大问题。

However, cacheing headers are unreliable in meta elements; 但是,缓存标题在元元素中是不可靠的; for one, any web proxies between the site and the user will completely ignore them. 例如,站点和用户之间的任何Web代理都将完全忽略它们。 You should always use a real HTTP header for headers such as Cache-Control and Pragma. 您应该始终为标头(如Cache-Control和Pragma)使用真正的HTTP标头。


#6楼

For modern web browsers (After IE9) 适用于现代网络浏览器(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 对于IE9和之前

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. 如果复制,第二个将覆盖第一个,第四个将覆盖第三个,因为http-equiv声明和W3C验证器失败。 At most, one could have one of each http-equiv declarations; 最多可以有一个http-equiv声明中的一个; pragma, cache-control and expires. 编译指示,缓存控制和过期。 These are completely outdated when using modern up to date browsers. 使用现代最新的浏览器时,这些已完全过时。 After IE9 anyway. 无论如何IE9之后。 Chrome and Firefox specifically does not work with these as you would expect, if at all. 如果有的话,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" />

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. 例如,站点和用户之间的任何Web代理都将完全忽略它们。 You should always use a real HTTP header for headers such as Cache-Control and Pragma. 您应该始终为标头(如Cache-Control和Pragma)使用真正的HTTP标头。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值