Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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:

JavaScript
/// 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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900