Created
November 9, 2012 10:41
-
-
Save killercup/4045091 to your computer and use it in GitHub Desktop.
HTML5 AppCache: SwapCache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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