1// Client-Side Caching using Service Worker and Browser-Cache-API 2 3const cacheVersion = "v0.3"; 4const cacheAssets = [ 5 '/css/css-coaching-welt-neuer-Header.css' 6] 7 8// Call Install Event 9self.addEventListener('install', (e) => { 10 console.log("SW: Installed"); 11 e.waitUntil( 12 caches 13 .open(cacheVersion) 14 .then(cache => { 15 console.log("Service Worker: Caching Files"); 16 cache.addAll(cacheAssets); 17 }) 18 .then(() => self.skipWaiting()) 19 ); 20}, false); 21 22// Call Activate Event 23self.addEventListener('activate', (e) => { 24 console.log("SW: Activated"); 25 // Remove old Cache Versions, if a newer one is available 26 e.waitUntil( 27 caches.keys().then(cacheNames => { 28 return Promise.all( 29 cacheNames.map(cache => { 30 if (cache !== cacheVersion) { 31 console.log("Service Worker: Old Cache deleted"); 32 return caches.delete(cache); 33 } 34 }) 35 ) 36 }) 37 ); 38}, false);
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.