diff options
author | navanchauhan <navanchauhan@gmail.com> | 2022-10-17 23:58:20 -0600 |
---|---|---|
committer | navanchauhan <navanchauhan@gmail.com> | 2022-10-17 23:58:20 -0600 |
commit | 01076278493fd722fc658e7d51b49267c9c37dff (patch) | |
tree | 56a111a0bdf3e4674fb832f766b6ec214699c59a /static/pwabuilder-sw.js | |
parent | 2231c15975634a730d213c51ec532177c0ddcf71 (diff) |
add service worker
Diffstat (limited to 'static/pwabuilder-sw.js')
-rw-r--r-- | static/pwabuilder-sw.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/static/pwabuilder-sw.js b/static/pwabuilder-sw.js new file mode 100644 index 0000000..860da8c --- /dev/null +++ b/static/pwabuilder-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 |