feoblog icon indicating copy to clipboard operation
feoblog copied to clipboard

Fix back behavior in iOS Safari

Open NfNitLoop opened this issue 3 years ago • 1 comments

See: https://gomakethings.com/fixing-safaris-back-button-browser-cache-issue-with-vanilla-js/

which recommends:

/**
 * If browser back button was used, flush cache
 * This ensures that user will always see an accurate, up-to-date view based on their state
 * https://stackoverflow.com/questions/8788802/prevent-safari-loading-from-cache-when-back-button-is-clicked
 */
(function () {
	window.onpageshow = function(event) {
		if (event.persisted) {
			window.location.reload();
		}
	};
})();

Need to investigate further and make sure that only affects Safari.

NfNitLoop avatar Aug 27 '22 23:08 NfNitLoop

That seems to have done the trick. Nice.

NfNitLoop avatar Aug 28 '22 16:08 NfNitLoop