<!DOCTYPE html>
<html lang="en-US">
<body onpageshow="myFunction()">
<h2>Welcome to this page</h2>
<script>
function myFunction() {
if(event.persisted)
alert("The page was cached by the browser");
else
alert("The page was NOT cached by the browser");
}
</script> </body>
</html>