diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 0000000..860da8c --- /dev/null +++ b/public/sw.js @@ -0,0 +1,18 @@ +// This is the "Offline copy of pages" service worker + +const CACHE = "pwabuilder-offline"; + +importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js'); + +self.addEventListener("message", (event) => { + if (event.data && event.data.type === "SKIP_WAITING") { + self.skipWaiting(); + } +}); + +workbox.routing.registerRoute( + new RegExp('/*'), + new workbox.strategies.StaleWhileRevalidate({ + cacheName: CACHE + }) +); \ No newline at end of file