1/* eslint-disable array-callback-return */ 2/* eslint-disable no-restricted-globals */ 3// Installing service worker 4const CACHE_NAME = "Yvener Duroseau"; 5 6/* Add relative URL of all the static content you want to store in 7 * cache storage (this will help us use our app offline)*/ 8let resourcesToCache = ["/bg-img.jpg"]; 9 10self.addEventListener("install", (e) => { 11 e.waitUntil( 12 caches.open(CACHE_NAME).then((cache) => { 13 return cache.addAll(resourcesToCache); 14 }), 15 ); 16}); 17// Cache and return requests 18self.addEventListener("fetch", (e) => { 19 e.respondWith( 20 caches.match(e.request).then((response) => { 21 return response || fetch(e.request); 22 }), 23 ); 24}); 25 26// Update a service worker 27const cacheWhitelist = ["Yvener Duroseau"]; 28self.addEventListener("activate", (event) => { 29 event.waitUntil( 30 caches.keys().then((cacheNames) => { 31 return Promise.all( 32 cacheNames.map((cacheName) => { 33 if (cacheWhitelist.indexOf(cacheName) === -1) { 34 return caches.delete(cacheName); 35 } 36 }), 37 ); 38 }), 39 ); 40});
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.