Skip to content

Instantly share code, notes, and snippets.

@glynrob
Created February 9, 2013 19:25
Show Gist options
  • Save glynrob/4746686 to your computer and use it in GitHub Desktop.
Save glynrob/4746686 to your computer and use it in GitHub Desktop.
App Cache detection and swap
// Check if a new cache is available on page load.
window.addEventListener('load', function(e) {
window.applicationCache.addEventListener('updateready', function(e) {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
// New update is ready.
window.applicationCache.swapCache(); // swap old cache with new one.
if (confirm('Your experience has been updated. \n Click OK to reload your page')) {
window.location.reload();
}
}
}, false);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment