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:


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) {

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

The History interface allows manipulation of the browser session history , that is the pages visited in the tab or frame that the current page is loaded in.

There are multiple ways to Refresh/Reload a page with jQuery/JavaScript, some are:

location.href = location.href
window.location = window.location
window.self.window.self.window.window.location = window.location