1function hostStartWithValidProtocol(requestUrl){ 2 return (requestUrl.indexOf('http') === 0); 3} 4 5function webwaveApplicationNonCacheUrls(requestUrl){ 6 return (requestUrl.indexOf('gui/fileUpload') !== -1 7 || requestUrl.indexOf('gui/saveAndPublishService') !== -1 8 || requestUrl.indexOf('webmasterPanel/exportWebsite') !== -1 9 || requestUrl.indexOf('administration/') !== -1 10 || requestUrl.indexOf('webmasterPanel/getWebsiteAccounts') !== -1 11 || requestUrl.indexOf('tawk.to') !== -1 12 || requestUrl.match(/\.(mp4)$/) !== null); 13} 14 15function hostIsValidUrl(requestUrl){ 16 if (hostStartWithValidProtocol(requestUrl)){ 17 return webwaveApplicationNonCacheUrls(requestUrl) === false; 18 } 19 return false; 20} 21 22self.addEventListener('install', event => { 23 //force new service worker when one is waiting 24 self.skipWaiting(); 25 event.waitUntil( 26 caches.open('v1').then(cache => { 27 return cache.addAll(['/manifest.json']); 28 }, error => { 29 console.log(`Installation failed with error: ${error}`); 30 }), 31 ); 32}); 33 34self.addEventListener('activate', event => {
35 let cacheKeepList = ['v1']; 36 event.waitUntil( 37 caches.keys().then(keyList => { 38 return Promise.all(keyList.map(function (key){ 39 if (cacheKeepList.indexOf(key) === -1){ 40 return caches.delete(key); 41 } 42 })); 43 }), 44 ); 45}); 46 47self.addEventListener('fetch', function (event){ 48 if (hostIsValidUrl(event.request.url) === false){ 49 return; 50 } 51 event.respondWith( 52 // Try the network 53 fetch(event.request) 54 .then(function (res){ 55 return caches.open('v1') 56 .then(function (cache){ 57 // Put in cache if succeeds 58 cache.put(event.request.url, res.clone()); 59 return res; 60 }); 61 }) 62 .catch(function (err){ 63 // Fallback to cache 64 return caches.match(event.request); 65 }), 66 ); 67});
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.