tags:

views:

159

answers:

2

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.

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.

+1  A: 

It sounds like your problem is related to this answer. After testing your header and the suggested headers, I could only reproduce your expected behavior in Internet Explorer.

Quai
I repeatedly reproduce this issue on Opera. It seems to be the only inconsistent browser. I have read about their strict, principled approach to handling caching. But this is practically just looking like a security hole without doing extra leg work. I'd really like an explicit solution that can be implemented to nishkarr's questions as well. The header cache control reponse headers do not work in opera as in other browsers. What is the work around?
ForerMedia
+1  A: 

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...)

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'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.

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).

hallvors
"This is a feature requested by and intended for paranoid banks, it slows down way too many normal sites if applied on http"Are you saying browsers shouldn't really be used for applications that may have sensitive data? :-)
bunn_online
If data is truly sensitive, sites should use https. :-)There is a hole in the web specifications here, as there is no concept of "sessions" shared between server and browser. If the server could tell the browser "the user just logged out/timed out and we closed her session, please disallow using back button to see history since the session was started" we'd be able to find a better balance between usability and security.
hallvors
ForerMedia
There is no way I know about to reliably force revalidation if you are not on https. We're working on proposals to fix this problem, for example: http://www.ietf.org/id/draft-pettersen-cache-context-05.txtAn actual implementation is probably some time away - pending further discussion of the proposal.
hallvors