1/* eslint-disable compat/compat */ 2 3var OFFLINE_PAGE = 'offline/index.html'; 4var OFFLINE_IMG = 'offline/offline.jpg'; 5 6self.addEventListener('install', function(event) { 7 event.waitUntil( 8 caches.open('offline').then(function(cache) { 9 return cache.addAll([OFFLINE_PAGE, OFFLINE_IMG]); 10 }) 11 ); 12}); 13 14self.addEventListener('fetch', function(event) { 15 var request = event.request; 16 17 if (event.request.mode === 'navigate') { 18 event.respondWith( 19 fetch(request).catch(function() { 20 return caches.match(OFFLINE_PAGE); 21 }) 22 ); 23 } else if (event.request.url.includes(OFFLINE_IMG)) { 24 event.respondWith( 25 caches.match(request).then(function(response) { 26 return response || fetch(request); 27 }) 28 ); 29 } 30});
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.