<html>
<body onpageshow="myFunction(event)">
<h1>Hello World!</h1>
<script>
function myFunction(event) {
if (event.persisted) {
alert("The page was cached by the browser");
} else {
alert("The page was NOT cached by the browser");
}
}
</script>
</body>
</html>