diff --git a/public/sw.js b/public/sw.js index c00c30b..6a9bfd6 100644 --- a/public/sw.js +++ b/public/sw.js @@ -14,8 +14,10 @@ self.addEventListener('fetch', (e) => { if (e.request.method !== 'GET') return; e.respondWith( caches.match(e.request).then((hit) => hit || fetch(e.request).then((res) => { - const copy = res.clone(); - caches.open(CACHE).then((c) => c.put(e.request, copy)); + if (res.ok && res.type === 'basic') { + const copy = res.clone(); + e.waitUntil(caches.open(CACHE).then((c) => c.put(e.request, copy))); + } return res; }).catch(() => caches.match('/index.html'))) );