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

查看:25
本文介绍了如何阻止 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天全站免登陆