Skip to content

Instantly share code, notes, and snippets.

@killercup
Created November 9, 2012 10:41
Show Gist options
  • Save killercup/4045091 to your computer and use it in GitHub Desktop.
Save killercup/4045091 to your computer and use it in GitHub Desktop.
HTML5 AppCache: SwapCache
window.applicationCache.addEventListener('updateready', function(e) {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
// Browser downloaded a new app cache.
// Swap it in and reload the page to get the new hotness.
window.applicationCache.swapCache();
if (confirm('A new version of this site is available. Load it?')) {
window.location.reload();
}
} else {
// Manifest didn't changed. Nothing new to server.
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment