Chrome back button: only giving cached version of initial page, without any Ajaxed content Chrome back button: only giving cached version of initial page, without any Ajaxed content ajax ajax

Chrome back button: only giving cached version of initial page, without any Ajaxed content


This topic is old but thought I would share my solution. To get Firefox, Chrome and Safari to behave consistently, you have to set an unload handler on the page that needs to be reloaded when going back, and also use cache busting headers.

Example

In HTTP Headers

Cache-Control: must-revalidate, no-store, no-cache, private

And in the javascript for the page

$(window).unload(function(){}); // Does nothing but break the bfcache

Read here for more info: http://madhatted.com/2013/6/16/you-do-not-understand-browser-history


I know that topic is old but solution to this problem is not so easy to find I've just wasted few hours to solve it. These two lines solved the Chrome problem for me:

Response.Cache.SetCacheability(HttpCacheability.NoCache);Response.Cache.SetNoStore();


Well, if you are using xhr request and not hidden frames the back and forward buttons do not tie in to xhr request