1var staticCacheName = "pwa-v" + new Date().getTime(); 2var filesToCache = [ 3 '/offline', 4 '/css/app.css', 5 '/js/app.js', 6 '/images/icons/apple-splash-640-1136.jpg', 7 '/images/icons/apple-splash-750-1334.jpg', 8 '/images/icons/apple-splash-828-1792.jpg', 9 '/images/icons/apple-splash-1125-2436.jpg', 10 '/images/icons/apple-splash-1242-2208.jpg', 11 '/images/icons/apple-splash-1242-2688.jpg', 12 '/images/icons/apple-splash-1536-2048.jpg', 13 '/images/icons/apple-splash-1668-2224.jpg', 14 '/images/icons/apple-splash-1668-2388.jpg', 15 '/images/icons/apple-splash-2048-2732.jpg' 16]; 17 18// Cache on install 19self.addEventListener("install", event => { 20 this.skipWaiting(); 21 event.waitUntil( 22 caches.open(staticCacheName) 23 .then(cache => { 24 return cache.addAll(filesToCache); 25 }) 26 ) 27}); 28 29// Clear cache on activate 30self.addEventListener('activate', event => { 31 event.waitUntil( 32 caches.keys().then(cacheNames => { 33 return Promise.all( 34 cacheNames 35 .filter(cacheName => (cacheName.startsWith("pwa-"))) 36 .filter(cacheName => (cacheName !== staticCacheName)) 37 .map(cacheName => caches.delete(cacheName)) 38 ); 39 }) 40 ); 41}); 42 43// Serve from Cache 44self.addEventListener("fetch", event => { 45 event.respondWith( 46 caches.match(event.request) 47 .then(response => { 48 return response || fetch(event.request); 49 }) 50 .catch(() => { 51 return caches.match('offline'); 52 }) 53 ) 54});
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.