Inclusion of Google Maps on the page disables bfcache (I will use the term mozilla due to the lack of a standard one), because the unload listener unload used on the map page loaded in the <iframe> .
Possible reasons for not caching a page for fast rewinding in Firefox are indicated in MDN: Using Firefox 1.5 caching . Your problem is listed as “a top-level page contains frames that are not cached”, which is confusing, I will try to clarify it later. (Other browsers probably use similar heuristics, as these rules were designed to not violate existing content - see also this answer , it has some links.)
The right way to fix this is to make friends with someone on Google and then warm them until they remove the onunload , at least from the built-in map pages.
In general, you should never rely on bfcache to work or not work on a specific page. This is just an optimization for the general case. Since this is an optimization, it can be disabled, for example, when the system remains low in memory. It will also not work if the user restarts the browser before returning or closes the tab and selects “cancel closing the tab”, as you noted in the error.
You must either restore the state of the page from JS, or mark the page as cacheable (using the HTTP header). The first, of course, leads to a better user experience. The @Adam Gent suggestion looks right, I will need to check which Firefox problem it is addressing.
The reason bfcache works as follows:
- If the browser launches the onunload handler and then restores the page via bfcache, the page may be damaged, because scripts often delete event listeners in the onunload handler (in order to “clear” what is not really necessary except the old IE version)
- if browsers have stopped using
onunload handlers on the page, based on the fact that the user can return to the page and they want to cache it, the authors will complain. - If the page in the iframe cannot be cached, restoring the external cached page and reloading the internal page sometimes interrupts it (for example, if both pages have the same domain, the external page may contain links to objects in the frame that will not be valid after the internal frame is reloaded). Therefore, if the iframe is not cached, none of them are parent.
The reason the page is still loading from the cache (disk) when you press back is because you allegedly indicated that the content sent to the browser could be cached. The browser does not know that you are updating the page on the server in parallel with the DOM changes.
Hope this helps.
[edit] I will talk about the idea of "mark the page as not cached" above. To make the web browser cache work, not against you, it is important to remember that HTTP is a protocol for retrieving resources. For example, the HTML page identified by the URL http://bbb.akshell.com/broken is a resource. When you serve a resource through HTTP, you specify how long a copy of the browser resource will be valid (i.e., it matches the canonical version of the resource on the server).
When, as in your test case, the resource is an HTML page with an element selected by the user, marked in a special way, the resource can change at any time (every time the user changes the choice). This means that an honest HTTP response when serving this resource will be "not cached, may change at any time." Then the browser will reload the page from the server every time it needs to load the page - the correct behavior, but due to the slowness for the user.
An alternative approach, suitable for things like switching between multiple tabs on a page, is to associate each selection with its own URL. A page with two tabs will correspond to two resources (and two URLs) - one for each tab. Both resources can be (HTTP) cached by the browser. Changing the URL and page content can be implemented without accessing the server via pushState.
Another approach that seems more applicable to your case, in which you save user input on the server: separate the application user interface and user data from different resources (for example, a static (HTTP) cached HTML page with JS, loading user data from a separate non-cacheable URLs). Request user data and update the user interface at boot. [/ Edit]