如何阻止Opera缓存页面? [英] How do I stop Opera from caching a page?

查看:96
本文介绍了如何阻止Opera缓存页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Opera每次都重新请求一个页面,而不是仅仅从缓存中提供它.我正在发送"Cache-control:no-cache"和"Pragma:no-cache"响应标头,但似乎Opera只是忽略了这些标头.它可以在其他浏览器(Chrome,IE,Firefox)中正常运行.

I am trying to get Opera to re-request a page every time instead of just serving it from the cache. I'm sending the 'Cache-control: no-cache' and 'Pragma: no-cache' response headers but it seems as if Opera is just ignoring these headers. It works fine in other browsers - Chrome, IE, Firefox.

如何停止Opera缓存页面?我想做的是,当用户单击浏览器上的后退"按钮时,Opera重新请求页面.

How do I stop Opera from caching pages? What I want to be able to do is have Opera re-request a page when the user clicks the Back button on the browser.

推荐答案

作为用户,我绝对讨厌使用后退"按钮时强制重新加载,从而减慢了历史导航的页面. (如果您每天使用的浏览器都注意各种缓存指令,并让它们以您希望作为开发人员的方式影响历史导航,您可能会注意到某些网站使您的浏览速度变慢了……)

As a user, I absolutely detest pages that slow down my history navigation by forcing re-loads when I use the back button. (If the browser you use on a daily basis paid attention to the various caching directives and let them affect history navigation the way you want as a developer you'd probably notice some sites slowing down yourself...)

如果您有很强的用例,那么您的架构在某种意义上可能是错误的",例如,如果您要在不断更新数据的不同视图"之间进行切换,因此希望当用户返回时强制重新加载,也许使用Ajaxy技术将不断变化的数据加载到当前页面会更好?

If you have a very strong use case for doing this I'd say your architecture might be "wrong" in some sense - for example, if you're switching between different "views" of constantly updating data and thus want to enforce re-load when users go back perhaps using Ajaxy techniques for loading the constantly changing data into the current page would be better?

Opera的实现是有目的的-缓存"在概念上与历史记录导航"不同,前者更多地是将内容存储在磁盘上和会话之间,后者则切换回您刚刚访问的临时隐藏页面,在您离开的状态.

Opera's implementation is on purpose - "caching" is seen as conceptually different from "history navigation", the former is more about storing things on disk and between sessions, the latter is switching back to a temporarily hidden page you just visited, in the state you left it.

但是,如果确实需要,则此策略中存在漏洞,可以启用您想要的行为.发送"缓存控制:必须重新验证"将强制Opera重新加载导航中的每个页面,但如果您通过https发送页面,则. (这是偏执狂银行所要求的功能,专门针对偏执狂的银行使用,如果在http上应用,它会减慢太多正常站点的速度.)

However, if you really, really need it there is a loophole in this policy that enables the behaviour you want. Sending "Cache-control: must-revalidate" will force Opera to re-load every page on navigation, but only if you're sending the page over https. (This is a feature requested by and intended for paranoid banks, it slows down way too many normal sites if applied on http).

这篇关于如何阻止Opera缓存页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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