Created
July 15, 2015 08:19
-
-
Save mholtzhausen/d706b0cde653ce910088 to your computer and use it in GitHub Desktop.
Fix Browser Page-Cache on pages that require reload for every view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
//For browsers that have an unmodified window.history object when navigating back | |
if (window.history.state != null && window.history.state.hasOwnProperty('historic')) { | |
if (window.history.state.historic == true) { | |
document.body.style.display = 'none'; | |
window.history.replaceState({historic: false}, ''); | |
window.location.reload(); | |
} else { | |
window.history.replaceState({historic: true, last_visit: new Date()}, ''); | |
} | |
} else { | |
window.history.replaceState({historic: true, last_visit: new Date()}, ''); | |
} | |
//For browsers that disable page cache when an onunload handler exists | |
window.onunload = function () { | |
}; | |
// For browsers that have the event.persisted property set for pages that have been cached | |
window.onpageshow = function (event) { | |
if (event.persisted) { | |
document.body.style.display = 'none'; | |
window.location.reload(); | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment