1 2const CACHENAME = 'eShop-Cache-V1'; 3const DYNAMICCACHE = 'eShop-Dynamic-Cache-V1'; 4const FILELIST = ['css/img/offline.jpg', './?offline=true']; 5 6self.addEventListener('install', function(e){ 7 e.waitUntil( 8 caches.open(CACHENAME).then(function(cache){ 9 return cache.addAll(FILELIST); 10 }) 11 ); 12}); 13 14self.addEventListener('activate', function(e){ 15 e.waitUntil( 16 caches.keys().then(function(keyList){ 17 return Promise.all(keyList.map(function(key){ 18 if(key !== CACHENAME){ 19 return caches.delete(key); 20 } 21 })); 22 }) 23 ); 24 return self.clients.claim(); 25}); 26 27self.addEventListener('fetch', function(e){ 28 if(e.request.url.includes("facebook")){ } 29 else if (e.request.method !== 'GET') { 30 return; 31 } else { 32 e.respondWith( 33 fetch(e.request).then(function(res){ 34 return caches.open(DYNAMICCACHE).then(function(cache){ 35 cache.put(e.request.url, res.clone()); 36 return res; 37 }) 38 }).catch(function(err){ 39 return caches.match(e.request).then(function(response){ 40 if(response){ 41 return response; 42 } else { 43 return caches.match('./?offline=true'); 44 } 45 }); 46 }) 47 ); 48 } 49});
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.