diff --git a/sw.js b/sw.js index 0a9bf7b..5abbd08 100644 --- a/sw.js +++ b/sw.js @@ -1,19 +1,6 @@ -const CACHE_NAME = 'opal-ai-v2-cache'; -const ASSETS = [ - './', - './index.html', - './style.css', - './app.js', - './manifest.json', - 'https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js' -]; +const CACHE_NAME = 'opal-ai-v5-cache'; self.addEventListener('install', (e) => { - e.waitUntil( - caches.open(CACHE_NAME).then((cache) => { - return cache.addAll(ASSETS); - }) - ); self.skipWaiting(); }); @@ -21,19 +8,14 @@ self.addEventListener('activate', (e) => { e.waitUntil( caches.keys().then((keys) => { return Promise.all( - keys.map((key) => { - if (key !== CACHE_NAME) return caches.delete(key); - }) + keys.map((key) => caches.delete(key)) ); - }) + }).then(() => self.clients.claim()) ); - self.clients.claim(); }); self.addEventListener('fetch', (e) => { e.respondWith( - caches.match(e.request).then((res) => { - return res || fetch(e.request); - }) + fetch(e.request).catch(() => caches.match(e.request)) ); });