js on document load does not execute on cache code example
Example 1: javascript empty cache and hard reload
window.history.forward(1);
Example 2: JS how to determine if page was cached
// https://developer.mozilla.org/en-US/docs/Web/API/PageTransitionEvent
window.addEventListener('pageshow', myFunction);
function myFunction(event) {
if (event.persisted) {
alert("The page was cached by the browser");
} else {
alert("The page was NOT cached by the browser");
}
}