Am I cached or not?

var serverTimestamp = <?php echo time(); ?>;
var localDate = new Date();
var localUTCString = localDate.toUTCString();
var UTCDate = new Date(localUTCString);
var clientTimestamp = UTCDate.getTime() / 1000;
if (clientTimestamp - serverTimestamp > (60 * 5))
document.querySelector('main').insertAdjacentHTML('afterbegin',`
<p class="feedback">
<button onclick="this.parentNode.remove()">dismiss</button>
This page might be out of date. You can try <a href="javascript:window.location=window.location.href">refreshing</a>.
</p>
`);
This page might be out of date. You can try refreshing.

--

--

--

A web developer and author living and working in Brighton, England. Everything I post on Medium is a copy — the originals are on my own website, adactio.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jeremy Keith

Jeremy Keith

A web developer and author living and working in Brighton, England. Everything I post on Medium is a copy — the originals are on my own website, adactio.com

More from Medium

Measuring the impact of a test variation in React with Amplitude and ConfigCat

Improve your Storybook workflows with Chromatic

How We Open Sourced An ESLint Plugin for Internationalization At OkCupid

Why we choose to adopt GraphQL