Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I submit a form and then press back, I sometimes get the message "Document expired" instead of the last page.

enter image description here

I used to get the following annoying message box instead (which now appears after a click on "Try Again"):

enter image description here

Now, I do know what this means and why Firefox shows this message. However, I want to just see the last viewed page instead - just as it was displayed a second ago. No popup, and no reloading to reflect the server's new state. (Maybe a little info bar would be nice, but it's not neccessary for me).

Use case: Imagine I logged in to a site I regularly use, and after pressing Enter I see in the corner of my eye a news headline on the login page. I'd like to click back and see the exact page I saw a second ago to click on the headline. If I view the front page logged in, or just reload it, I might get different (randomized) headlines.

So how do I get rid of the "Document expired" and "Confirm" messages completely and get Firefox to simply display the cached last location after submitting a POST form? about:config settings, extensions, proxy tricks are all fine.

share|improve this question
3  
You 're asking how to display the cache entry of a non cached document. It's not possible. –  paa Apr 17 '13 at 20:26
2  
Well, then by extension I'm asking how to make Firefox also cache the document :-). –  jdm Apr 18 '13 at 6:51
1  
I encounter this a lot when all I'm trying to do is to backup through browsing history to get to somewhere before the problem occurred. Having something to get past this roadblock would be very useful. I know I can use the History button on the main toolbar, but it's often hard to figure out which entry to choose. –  Joe Apr 23 '13 at 22:18
    
@jdm you're asking 1) how to display the page I've navigated away in the same manner I've seen it before; 2) and how to get rid of browser's confirmation box to resend the data. Did I understand that clearly? –  laika May 10 '13 at 14:17
    
@sjrco: 1) yes, but not 2). I'd like to be able to click back and see what was there (same page state) before I navigated away. (That works on some pages even though they have been modified by js, or the user filled out forms, so the browser must save the modified document under some circumstances). I don't want the browser to silently resend data. I do want to suppress modal dialogs when it doesn't resend data, though. –  jdm May 10 '13 at 17:35

3 Answers 3

The Firefox engine does not (or should not) cache the last state of documents, only the HTML document itself if the server allows caching. Opera had (or maybe still has) this feature, but it has caused many security headaches for website operators.

RFC 2616 states:

13.4 Response Cacheability

Unless specifically constrained by a cache-control (section 14.9) directive, a caching system MAY always store a successful response (see section 13.8) as a cache entry, MAY return it without validation if it is fresh, and MAY return it after successful validation.

A lot of sites nowadays employ the cache-control header on all responses generated by the server to avoid caching problems. Even if you get Firefox to give you the document in the former state, on the majority of sites if wouldn't or shouldn't work anyway. The safest and most future-proof solution would be to ask the website owner to code their website properly.

share|improve this answer
1  
But it does cache the last state, at least in some circumstances. Try this: gist.github.com/jdmansour/5578079 . At least the DOM is preserved. –  jdm May 14 '13 at 18:05
1  
History and cache are not the same thing. See section 13.13 of the same RFC. The back button requests a redisplay of a history entry, not a cache entry. Opera is right; Firefox is wrong. Anyone who claims this is a "security" feature is being stupid. You can always use "open in new tab", then close the new tab to see the previous page without the server knowing that you have done so. A properly functioning back button should have exactly that effect. –  Wumpus Q. Wumbley Aug 17 '13 at 21:15

The answer is on https://support.mozilla.org/fr/questions/1010942 : just check Tools->Options->Override Automatic Cache Management.

share|improve this answer
    
This is it! The setting is under Tools / Options / Advanced / Network / Override automatic cache management. Not sure if it works for all cases of "Document Expired", but it worked for the one I had, where I was unable to View Source of a POST response. –  romkyns Apr 13 at 20:07
    
This shouldn't have any effect on this problem, since it only allows you to set the cache size: support.mozilla.org/en-US/questions/1037647 I wonder what the automatically determined cache size was if this does help... –  Nickolay Jul 26 at 19:58

To get rid of all these messages add the following PHP lines to the beginning of all your scripts:

header("Expires: Sat, 01 Jan 2000 00:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: post-check=0, pre-check=0",false); session_cache_limiter("must-revalidate");

share|improve this answer
1  
I'm not sure @jdm has control over the page(s) they're talking about. –  Valmiky Arquissandas Jul 25 '14 at 0:53

protected by Community Apr 29 at 2:55

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.