I have the following simple JavaScript, which I require in order to re-initialise some variables on page reload, specifically when the page is served from the Safari BFCache
I appeared to have solved the issue by instead binding to the popstate
event:
jQuery(window).bind('popstate', function(event) {
// Do some initialisation here
});
which fires whenever the active history entry changes. This appears to fire consistently rather than just once, so achieves the goal of performing re-initialisation whenever a user lands on page, regardless of the mechanism for getting there.
To disable the BFCache
, you could add an onunload=""
attribute on your html body.
<body onunload=""></body>