14

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.

7
  • 3
    You 're asking how to display the cache entry of a non cached document. It's not possible.
    – paa
    Apr 17, 2013 at 20:26
  • 3
    Well, then by extension I'm asking how to make Firefox also cache the document :-).
    – jdm
    Apr 18, 2013 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, 2013 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, 2013 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, 2013 at 17:35

3 Answers 3

2

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.

2
  • 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, 2013 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.
    – user240960
    Aug 17, 2013 at 21:15
2

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");

1
  • 2
    I'm not sure @jdm has control over the page(s) they're talking about. Jul 25, 2014 at 0:53
2

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

2
  • 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.
    – RomanSt
    Apr 13, 2015 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, 2015 at 19:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .