1const offlineUrl = '/offline'; 2 3self.addEventListener('install', function(event) { 4 let offlineRequest = new Request(offlineUrl); 5 event.waitUntil( 6 fetch(offlineRequest).then(function(response) { 7 return caches.open('offline').then(function(cache) { 8 console.log('[oninstall] Cached offline page', response.url); 9 return cache.put(offlineRequest, response); 10 }); 11 }) 12 ); 13}); 14 15self.addEventListener('fetch', function(event) { 16 let request = event.request; 17 18 if (request.url.match(/\.(css|jpg|jpeg|png|gif|js|woff|woff2|ttf|svg|mp4|webp)$/) || request.url.indexOf(request.referrer) !== 0) { 19 return; 20 } else if (request.method === 'GET') { 21 event.respondWith( 22 fetch(request).catch(function(error) { 23 console.log( 24 '[onfetch] Failed. Serving cached offline fallback ' + 25 error 26 ); 27 return caches.open('offline').then(function(cache) { 28 return cache.match(offlineUrl); 29 }); 30 }) 31 ); 32 } 33});
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.