Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Cache Offline HTML5/CSS
Hi,
 
I've got a website which uses a cache manifest so it can work offline. I've recently had a problem where I've switched the live site to a holding page. This switches any requests for the cache manifest to return a http 404.
 
In this instance the whole page tried to update and ended up killing the application resulting in the main page reloading with again another 404 result.
 
The client device is an iPad.
 
The following is my code:
 
/// Start Cache Manifest

swapCM = function (e) {
    try { window.applicationCache.swapCache(); } catch (ex) { }
    $('divLoadingText').innerHTML = 'Loading new application version...'
    setTimeout(window.location.reload, 2000);
};
 
window.addEventListener('load', function (e) {
 
    $('divLoadingText').innerHTML = 'Checking current application version...'
 
    window.applicationCache.addEventListener('updateready', swapCM, false);
 
    if (window.applicationCache.status != window.applicationCache.UPDATEREADY) {
    }
 
    window.applicationCache.update();
 
}, false);
 
Does anyone know how this can be modified to check for none http 200 results and to ignore the refresh when this happens?
Posted 5-Nov-12 6:44am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 274
1 Shweta N Mishra 216
2 PIEBALDconsult 210
3 Sergey Alexandrovich Kryukov 185
4 BillWoodruff 174
0 OriginalGriff 7,620
1 Sergey Alexandrovich Kryukov 6,937
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,495


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 5 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100