Streaming live at 10am (PST)

Force refresh page when user taps browser back button

I need to somehow detect that the user has pressed a browsers back button and reload the page with refresh. There are some comments on Stack Overflow about it:

I’m not sure how I would implement this into my webflow project. Anyone ever had to do this?

Cheers :slight_smile:

Hello!

I have had to solve this issue in the past, specifically for Safari users since Safari slides back to the exit state of the previous page when going back. Below is the custom code that worked for me to accomplish this:

/* If browser back button was used, flush cache */
(function () {
	window.onpageshow = function(event) {
		if (event.persisted) {
			window.location.reload();
		}
	};
})();

This is the article where the code originally came from as well: