Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is caused by <a href="https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching" rel="noreferrer">back-forward cache</a>. It is supposed to save complete state of page when user navigates away. When user navigates back with back button page can be loaded from cache very quickly. This is different from normal cache which only caches HTML code.</p> <p>When page is loaded for bfcache <code>onload</code> event wont be triggered. Instead you can check the <code>persisted</code> property of the <code>onpageshow</code> event. It is set to false on initial page load. When page is loaded from bfcache it is set to true.</p> <pre><code>window.onpageshow = function(event) { if (event.persisted) { alert("From back / forward cache."); } }; </code></pre> <p>For some reason jQuery does not have this property in the event. You can find it from original event though.</p> <pre><code>$(window).bind("pageshow", function(event) { if (event.originalEvent.persisted) { alert("From back / forward cache."); } }); </code></pre> <p>Quick solution to these problem is to reload the page when back button is pressed. This however nullifies any positive effect back / forward cache would give.</p> <pre><code>window.onpageshow = function(event) { if (event.persisted) { window.location.reload() } }; </code></pre> <p>As a sidenote, you can see lot of pages offering using empty <code>onunload</code> handler as solution. This has not worked since iOS5.</p> <pre><code>$(window).bind("unload", function() { }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload