htmlapplication-cache

AppCache: Resources won't reload


When I update my manifest, and load the page, then I checked on Developer tools the scripts that I've changed. It's not there. I always need to clear my browser cache in order for it to be loaded. I have a listener for updating cache:

$(function() {    
    if (window.applicationCache) {
    applicationCache.addEventListener('updateready', function() {        
        console.log("appcache updated");
            window.location.reload();

    });
    }
}

Solution

  • There are quite a few gotchas when working with the AppCache.

    The first thing I would suggest is to add the swapCache method to your code above. E.g.

       $(function() {    
         if (window.applicationCache) {
           applicationCache.addEventListener('updateready', function() {        
             if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
               window.applicationCache.swapCache();
               console.log("appcache updated");
               window.location.reload();
             }
           });
         }
       }
    

    Here are a few other things to look out for:

    There are also quite a create answers to AppCache questions elsewhere on stackoverflow.

    If these don't help, perhaps post up some code and we can work it out.