PageSourceSearch

https://www.martin-chiro.com/pwabuilder-sw

js martin-chiro.com collected 2026-09-27 04:11:33 UTC 1,263 bytes, 49 lines download raw bytes

1// This is the "Offline page" service worker
2//
3// update?
4
5importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');
6
7const CACHE = "pwabuilder-page";
8
9// TODO: replace the following with the correct offline fallback page i.e.: const offlineFallbackPage = "offline.html";
10const offlineFallbackPage = "/";
11
12self.addEventListener("message", (event) => {
13  if (event.data && event.data.type === "SKIP_WAITING") {
14    self.skipWaiting();
15  }
16});
17
18self.addEventListener('install', async (event) => {
19  event.waitUntil(
20    caches.open(CACHE)
21      .then((cache) => cache.add(offlineFallbackPage))
22  );
23});
24
25if (workbox.navigationPreload.isSupported()) {
26  workbox.navigationPreload.enable();
27}
28
29self.addEventListener('fetch', (event) => {
30  if (event.request.mode === 'navigate') {
31    event.respondWith((async () => {
32      try {
33        const preloadResp = await event.preloadResponse;
34
35        if (preloadResp) {
36          return preloadResp;
37        }
38
39        const networkResp = await fetch(event.request);
40        return networkResp;
41      } catch (error) {
42
43        const cache = await caches.open(CACHE);
44        const cachedResp = await cache.match(offlineFallbackPage);
45        return cachedResp;
46      }
47    })());
48  }
49});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.