Reload explicit html5 manifest

I had a strange problem with the HTML5 manifest file in Chrome 5.0.375.99, but everything works fine in Safari.

When I first load the page with the manifest file specified for the first time, I can observe, using Fiddler, that all the files in the downloadable manifest and then halfway through it seem to get the manifest file again. At this point, an error event is fired and the applicationCache status is UNCACHED.

I tried the following

  • reboot pc
  • restart browser
  • check that the number of cached files does not exceed 5 MB.
  • verify that the files in the manifest file are valid by doing HEAD
  • Tried to use a different manifest file name
+3
source share
2 answers

I just installed the Chrome dev channel and the problem still occurs, but now the error log is better and I get the event "Application caching error: manifest changed during update, scheduling retry"

Chrome seems to check the manifest file if it changes just before loading the last entry in the manifest file. The error occurs because I used the current timestamp value in a dynamically generated manifest file.

Used timestamp of the time when my assembly was built and the problem disappeared. :)

+9
source

I finally decided it at my end.

I am lazy and I want my server to dynamically generate my cache manifest for me.

- - .

, node:

//OFFLINE CACHE
var cacheManifest = undefined;

exports.cache = function(req, res){
    if (!cacheManifest) {
        var fsutils = require('modules/utils/fsutils');
        //get the files and generate the output for cache.manifest
        fsutils.getFiles('/public', function(files) {
            var out = 'CACHE MANIFEST\n\ ';
            var len = files.length;
            for (var i = 0; i < len; ++i) {
                out += files[i] + '\n\ ';
            }
            //setup for second request
            cacheManifest = out;
            //send output
            res.header('Content-Type', 'text/cache-manifest');
            res.end(out);
        });
    } else {
        console.log('cache is cahced');
        res.header('Content-Type', 'text/cache-manifest');
        res.end(cacheManifest);
    }
};

, . , , , .

, , .

, () - doc , chrome , .

.....

+1

Source: https://habr.com/ru/post/1754749/


All Articles