1var CACHE_NAME = "foodie-vvn"; 2var urlsToCache = ["/", "/completed"]; 3 4// Install a service worker 5self.addEventListener("install", (event) => { 6 // Perform install steps 7 event.waitUntil( 8 caches.open(CACHE_NAME).then(function (cache) { 9 console.log("Opened cache"); 10 return cache.addAll(urlsToCache); 11 }) 12 ); 13}); 14 15// Cache and return requests 16self.addEventListener("fetch", (event) => { 17 event.respondWith( 18 caches.match(event.request).then(function (response) { 19 // Cache hit - return response 20 if (response) { 21 return response; 22 } 23 return fetch(event.request); 24 }) 25 ); 26}); 27 28// Update a service worker 29self.addEventListener("activate", (event) => { 30 var cacheWhitelist = ["foodie-vvn"]; 31 event.waitUntil( 32 caches.keys().then((cacheNames) => { 33 return Promise.all( 34 cacheNames.map((cacheName) => { 35 if (cacheWhitelist.indexOf(cacheName) === -1) { 36 return caches.delete(cacheName); 37 } 38 }) 39 ); 40 }) 41 ); 42});
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.