diff --git a/pwa/sw.js b/pwa/sw.js index 20cc77e..ec48e50 100644 --- a/pwa/sw.js +++ b/pwa/sw.js @@ -4,7 +4,11 @@ const CACHE = "pwabuilder-offline-page"; importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js'); -const offlineFallbackPage = "404"; +const PRECACHE_ASSETS = [ + '/', + '/404' +] + self.addEventListener("message", (event) => { if (event.data && event.data.type === "SKIP_WAITING") { @@ -15,7 +19,7 @@ self.addEventListener("message", (event) => { self.addEventListener('install', async (event) => { event.waitUntil( caches.open(CACHE) - .then((cache) => cache.add(offlineFallbackPage)) + .then((cache) => cache.addAll(PRECACHE_ASSETS)) ); }); @@ -45,7 +49,7 @@ self.addEventListener('fetch', (event) => { } catch (error) { const cache = await caches.open(CACHE); - const cachedResp = await cache.match(offlineFallbackPage); + const cachedResp = await cache.match('/404'); return cachedResp; } })()); diff --git a/templates/index.html b/templates/index.html index 7c14be8..70b38b1 100644 --- a/templates/index.html +++ b/templates/index.html @@ -50,7 +50,12 @@ -{{handshake_scripts | safe}} + +{{handshake_scripts | safe}}