I'm using the application cache for an offline mode for my application, and the main page will be changed often, so I want to update the cache every time the HTML page is updated.
Or, to update the cache for every page's load.
I'm using this code, but it doesn't work:
window.addEventListener('load', function(e) {
window.applicationCache.addEventListener('updateready', function(e) {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
// Browser downloaded a new app cache.
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);
}, false);