diff --git a/resources/private/worker.js b/resources/private/worker.js index 5f07636..23df3d6 100644 --- a/resources/private/worker.js +++ b/resources/private/worker.js @@ -1,10 +1,11 @@ const relatedAppVersion = '1'; // prop:relatedAppVersion const urlsToCache = ["/", "index.html", "js/app.js", "css/styles.css", "img/icon.svg", "manifest.json"]; // prop:urlsToCache -const cacheKey = `resources.${relatedAppVersion}`; +const cacheKeyPrefix = 'nenadalm.backgammon.'; +const cacheKey = `${cacheKeyPrefix}resources.${relatedAppVersion}`; function ensureHtmlVersionMatches(cache) { - return cache.match(new Request('/index.html')) + return cache.match(new Request('index.html')) .then(response => response.text()) .then(html => html.match(//)[1]) .then(version => { @@ -23,6 +24,7 @@ self.addEventListener('install', event => { self.addEventListener('activate', event => { event.waitUntil( caches.keys() + .then(keys => keys.filter(key => key.startsWith(cacheKeyPrefix))) .then(keys => keys.filter(key => key !== cacheKey)) .then(oldKeys => Promise.all(oldKeys.map(key => caches.delete(key)))) );