如何防止在Firefox中从Back-Forward缓存中显示内容? [英] How to prevent content being displayed from Back-Forward cache in Firefox?

查看:154
本文介绍了如何防止在Firefox中从Back-Forward缓存中显示内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

浏览器:火狐6.0



我有页面A与以下设置,以确保内容不存储在
$ b $ 1 $ <$ c $ <$ c $ $> $(window).unload(function(){});


$ b 2)
$ b

 < meta http-equiv =pragmacontent =no-cache/> 
< meta http-equiv =expirescontent = - 1/>
< meta http-equiv =cache-controlcontent =no-cache/>

我也连接了事件 pagehide pageshow 。当我离开页面导航时,事件属性 persisted = false 的CORRECT值调用 pagehide

浏览了几页之后,我找到了一个 window.history.go(-2 ); 回到页面A.此时,我希望Firefox能够轮询服务器的更新版本,而不是从缓存中显示。页面A的 pageshow 用事件属性 persisted = false 的CORRECT值调用(意味着页面不被加载来自缓存)。但页面内容不是服务器数据;这是陈旧的内容(与最初从页面导航时相同)! Fiddler也不会向服务器显示新的请求。



Google Chrome也具有相同的行为。 IE浏览器工作正常(重新载入新的数据)!

任何想法我缺少什么?




解决方案

涉及多个缓存。浏览器的文档缓存(bfache),浏览器的HTTP缓存,以及可能的中间HTTP缓存。 $ b < meta> 标记在当前的Chrome或Firefox中完全没有影响。它们可能在IE中有效果。

因此,您的页面正在从浏览器的HTTP缓存中读取。



如果你真的想发送no-cache HTTP头,你应该这样做。但是它们需要是实际的HTTP头文件:正如我上面所说的,< meta> 标签等价物什么也不做。 b

而且,重要的是,任何其他的中间缓存都不会解析你的HTML,所以如果你实际上没有发送正确的HTTP头文件,可能会缓存一些东西。


Browser: Firefox 6.0

I've Page A with the following setup to make sure the content is NOT stored in the bfcache of the browser:

1) $(window).unload(function(){});

2) Following HTTP headers:

<meta http-equiv="pragma" content="no-cache" /> 
<meta http-equiv="expires" content="-1" />
<meta http-equiv="cache-control" content="no-cache"/>

I've also hooked up the events pagehide and pageshow. When I am navigating away from the page, pagehide is invoked with CORRECT value for the event property persisted = false (that is what needed: no persistence in cache!)

After navigating a couple of pages, I've a window.history.go(-2); to go back to Page A. At this point, I want Firefox to poll the server for the updated version instead of displaying from the cache. The pageshow of Page A is invoked with CORRECT value for the event propertypersisted = false (meaning the page is NOT loaded from cache). BUT the page content is not the server data; it is the stale content (same as when navigating away from the page initially)! Fiddler also does not show a new request to server.

Google Chrome also exhibits the same behaviour. IE works as expected (reloads fresh data)!

Any idea what am i missing?

Thanks in advance!

解决方案

There are multiple caches involved. There's the browser's document cache (bfache), the browser's HTTP cache, and possibly intermediate HTTP caches.

The <meta> tags you show above have absolutely no effect in current Chrome or Firefox. They may have an effect in IE.

So chances are, your page is just being read from the browser's HTTP cache.

If you really want to send no-cache HTTP headers, you should do that. But they need to be actual HTTP headers: as I said above, the <meta> tag "equivalents" do nothing.

And, importantly, any other intermediate caches are not going to be parsing your HTML so might cache things if you don't actually send the right HTTP headers.

这篇关于如何防止在Firefox中从Back-Forward缓存中显示内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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