summaryrefslogtreecommitdiff
path: root/static/pwabuilder-sw.js
blob: 860da8c853aea3e2ee9d1123b55350c3b0cfdd50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
  })
);