Created
February 9, 2013 19:25
-
-
Save glynrob/4746686 to your computer and use it in GitHub Desktop.
App Cache detection and swap
This file contains hidden or 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
// 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