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:
jQuery(window).bind('pageshow', function(event) {
// I could inspect event.originalEvent.persisted here to check for BFCache hits,
// but it isn't required in this instance.
// Do some initialisation here
});
Let's say the user follows the below path, navigating to pages B and C, browsing back (i.e. using the back button) to page A after each:
A -> B -> A -> C -> A
The pageshow
handler only fires for the first and second visits to A, i.e. the initial page load and the first BFCache load. So in essence, it seems pages served from the BFCache fire pageshow
once and only once.
Is this the expected behaviour on Safari, and is there a way around it?