1const offlineUrl = '/offline' 2 3self.addEventListener('install', function(event) { 4 const 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 const 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 } else if (request.method === 'GET') { 20 event.respondWith( 21 fetch(request).catch(function(error) { 22 console.log('[onfetch] Failed. Serving cached offline fallback ' + error) 23 return caches.open('offline').then(function(cache) { 24 return cache.match(offlineUrl) 25 }) 26 }) 27 ) 28 } 29})
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.