Answers for "JS how to determine if page was cached"

0

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");
  }
}
Posted by: Guest on June-16-2020

Code answers related to "JS how to determine if page was cached"

Code answers related to "Javascript"

Browse Popular Code Answers by Language