1const expectedCaches = ['payce-offline-v13']; 2const cacheName = 'payce-offline-v13'; 3 4//Install stage sets up the offline page in the cahche and opens a new cache 5self.addEventListener('install', function (event) { 6 self.skipWaiting(); 7 event.waitUntil(preLoad()); 8}); 9 10var preLoad = function () { 11 return caches.open(cacheName).then(function (cache) { 12 //console.log('Payce Cached offline page during Install'); 13 return cache.addAll([ 14 '/offline.html', 15 '/Content/bootstrap/css/bootstrap.css', 16 '/Content/bootstrap/css/app.css?' + Math.floor(Math.random() * 10), 17 '/Scripts/jquery-3.5.1.min.js', 18 '/Scripts/bootstrap/bootstrap.js', 19 '/Scripts/fontawesome-all.js', 20 '/Scripts/jquery-plugins/jquery.maskedinput.js', 21 '/Scripts/site.js?03092022' 22 ]); 23 }); 24} 25 26self.addEventListener('activate', event => { 27 // delete any caches that aren't in expectedCaches 28 // which will get rid of prior versions 29 event.waitUntil( 30 caches.keys().then(keys => Promise.all( 31 keys.map(key => { 32 if (!expectedCaches.includes(key)) { 33 return caches.delete(key); 34 } 35 }) 36 )).then(() => { 37 //console.log(cacheName + ' now ready to handle fetches!'); 38 }) 39 ); 40}); 41 42self.addEventListener('fetch', function (event) { 43 //console.log('Fetch event for ', event.request.url); 44 event.respondWith( 45 caches.match(event.request).then(function(response) { 46 if (response) { 47 //console.log('Found ', event.request.url, ' in cache'); 48 return response; 49 } 50 //console.log('Network request for ', event.request.url); 51 return fetch(event.request); 52 53 }).catch(function(error) { 54 console.info('Network request Failed. Serving offline page'); 55 return returnFromCache('offline.html'); 56 }) 57 ); 58}); 59 60var returnFromCache = function (request) { 61 return caches.open(cacheName).then(function (cache) { 62 return cache.match(request).then(function (matching) { 63 if (!matching || matching.status === 404) { 64 return cache.match('offline.html'); 65 } else { 66 return matching; 67 } 68 }); 69 }); 70};
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.