I'm building a progressive web app and the service worker looks like this:
CURRENT_CACHE = 'V3'; FILES_TO_CACHE = [ '/index.html', '/js/bcheck.js', '/js/mss.js', '/js/vendor.js' ]; console.info('in file'); self.addEventListener('install', function (event) { console.info('installed'); event.waitUntil(caches.open(CURRENT_CACHE).then(function(cache){ return cache.addAll(FILES_TO_CACHE); })); }); self.addEventListener('activate', function (event) { console.info('activated'); event.waitUntil(caches.keys().then(function (cachesNames) { return Promise.all(cachesNames.map(function (cacheName) { if (cacheName !== CURRENT_CACHE) { return caches.delete(cacheName); } })) })); }); self.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request) .then(function(response) { // Cache hit - return response if (response) { return response; } return fetch(event.request); } ) ); });
I see that after the installation I get all my files cached, but when I put the server offline and reload nothing works, it like the service is offline and nothing loads.
Thanks for the help
- I work with local server HTTP on localhost