HTML5 Offline Application files using Cache manifest never get updated

I have developed an HTML5 mobile app with jQueryMobile and I am trying to provide a standalone function to allow users to use the app without an internet connection. I am following this tutorial:

  • The manifest file has been created.
  • Added mime-type / cache-manifest type manifest to .htaccess file.
  • Pages contain a manifest file in an HTML tag.

I am testing it and it seems to work. When I'm offline, web navigation between my pages still works. However, I find two main problems:

1) Offline works when I get a connected app and then shutdown it. When opening the app from the browser of the mobile device, pointing the URL in the address bar without connecting, the web app does not load! Although I previously visited the web app.

2) Web application files are never updated. For example:

  • I am changing something in the encrypted CSS file.
  • I am updating the comment in the manifest file to tell the application to update its files.
  • The CSS file is never updated. The current version is the previous one.

I am trying to detect cache status from JavaScript to control page refresh:

function checkCacheVersion(){
    var webappCache = window.applicationCache;
        //0-> unchached
        //1-> idle
        //2-> checking
        //3-> downloading
        //4-> updateready
        console.log('Cache state= ' +  webappCache.status);
        if(webappCache.status == window.applicationCache.UPDATEREADY){
            console.log('[Cache] There is an update waiting for reload');


However, the cache status is always "idle" status. What does it mean? As far as I understand, I would get "Uncached" status if the cache was not configured properly. Right?

On the other hand, the sample CSS file is only updated if I remove it from the manifest file. This way the browser detects that the file is not being caught and receives it correctly (I mean the cache is set up correctly, right?).

Could you help me figure out where the problem is? Many thanks!



source to share

All Articles