1const version = 1; 2const cacheName = "cfs-webapp" + version; 3 4const precachedAssets = [ 5 '/bootstrap/js/bootstrap.min-n.js', 6 '/framework/js/min/jQueryRotate-min.js' 7]; 8 9 10self.addEventListener('install', (event) => { 11 event.waitUntil( 12 caches 13 .open(cacheName) 14 .then((cache) => { 15 return cache 16 .addAll( 17 precachedAssets.map((urlToPrefetch) => { 18 return new Request(urlToPrefetch, { mode: "no-cors" }); 19 }), 20 ) 21 .then(() => { 22 console.log("All resources have been fetched and cached."); 23 }); 24 }) 25 .catch((error) => { 26 console.error("Pre-fetching failed:", error); 27 }), 28 ); 29}); 30 31self.addEventListener('activate', function (event) 32{ 33 event.waitUntil(self.clients.claim()); 34}); 35 36self.addEventListener('fetch', (event) => { 37 38 const url = new URL(event.request.url); 39 const isImage = url.pathname.includes('.webp') || url.pathname.includes('.png') || url.pathname.includes('.jpg'); 40 const isJS = url.pathname.includes('.js'); 41 const isCSS = url.pathname.includes('.css'); 42 43 if (( isImage || isJS || isCSS ) && !event.request.url.includes("chrome-extension")) { 44 event.respondWith(caches.open(cacheName).then((cache) => { 45 // Go to the cache first 46 return cache.match(url.origin + url.pathname).then((cachedResponse) => { 47 // Return a cached response if we have one 48 if (cachedResponse) { 49 return cachedResponse; 50 } 51 52 // Otherwise, hit the network 53 return fetch(event.request).then((fetchedResponse) => { 54 // Add the network response to the cache for later visits 55 cache.put(url.origin + url.pathname, fetchedResponse.clone()); 56 57 // Return the network response 58 return fetchedResponse; 59 }); 60 }); 61 })); 62 } else { 63 return; 64 } 65 });
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.