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