1"use strict"; 2 3const CACHE_NAME = 'ishins.com-1595014672336'; 4const SW_SUPPORTED_PROTOCOL_REGEX = /http(s?):/; 5const pageUrls = JSON.parse('["/","/our-company"]'); 6const staticAssets = JSON.parse('["//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/8396e10278a51439/styles.css","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/a00889bed639708d/styles.css","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/6c0614f26dd908ae/styles.css","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/f3a2e2ac93886842/styles.css","https://img1.wsimg.com/poly/v2/polyfill.min.js?unknown=polyfill&flags=gated&features=default%2Cfetch%2CArray.prototype.%40%40iterator%2CArray.prototype.find%2CArray.prototype.findIndex%2CFunction.name%2CNumber.isFinite%2CPromise%2CString.prototype.repeat%2CMath.sign%2CMath.trunc%2CArray.prototype.includes%2CObject.entries%2CObject.values%2CObject.is%2CIntersectionObserver%2CIntl.~locale.en-US","//img1.wsimg.com/blobby/go/gpub/79fb68164481d54f/script.js","//img1.wsimg.com/blobby/go/gpub/215ece480f300dfa/script.js","//img1.wsimg.com/ceph-p3-01/website-builder-data-prod/static/widgets/UX.3.63.17.js","//img1.wsimg.com/blobby/go/gpub/454286c5e2c349f6/script.js","//img1.wsimg.com/blobby/go/gpub/9b757a1e28962547/script.js","//img1.wsimg.com/blobby/go/gpub/992197d1a900c04c/script.js","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/1dfdb1e011ecee8e/script.js","//img1.wsimg.com/blobby/go/gpub/69d98b7fce170fe2/script.js","//img1.wsimg.com/blobby/go/gpub/eb031feddb815e74/script.js","//img1.wsimg.com/blobby/go/gpub/2d3dd1f9020d8d21/script.js","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/94b3ecf47f450c51/script.js","//img1.wsimg.com/blobby/go/gpub/fe432c2d11d8087f/script.js","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/a8b84180f8f2cd22/script.js","//fonts.googleapis.com/css?family=Bitter:700&display=swap","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/8d942c5ccdf71294/styles.css","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/e49a8ebc5372d904/styles.css","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/a9bdc33e7d6f6386/styles.css","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/67a2efc83e6fc835/script.
6js","//img1.wsimg.com/blobby/go/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/gpub/bf2ca0368fd0351/script.js"]'); 7const networkOnlyUrls = JSON.parse('["https://api.ola.godaddy.com","https://b34ddc92-da8d-4b80-ab33-9fc1c51c6190.onlinestore.godaddy.com","https://img.secureserver.net/t/1/tl/event","https://img.test-secureserver.net/t/1/tl/event","https://www.google-analytics.com/collect"]'); 8const networkOnlyUrlsRegex = JSON.parse('["ishins.com/m/api/.*","ishins.com(?:/.*)?/ola/services/.*","ishins.com/ola/meetings/.*","securepay.godaddy.com/api/apps/ola/accounts/.*"]').map(regexString => new RegExp(regexString)); 9const networkThenCacheUrls = JSON.parse('["https://blog.apps.secureserver.net/v1/website/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/feed/post/","https://blog.apps.secureserver.net/v1/website/b34ddc92-da8d-4b80-ab33-9fc1c51c6190/feed"]'); 10const networkThenCacheUrlsRegex = JSON.parse('["ishins.com(?:/.*)?/f/.*"]').map(regexString => new RegExp(regexString)); 11self.addEventListener('unhandledrejection', function (event) { 12 // eslint-disable-next-line no-console 13 console.warn('sw unhandledrejection error: ', event.reason); 14}); 15 16function preCacheResources() { 17 return caches.open(CACHE_NAME).then(function (cache) { 18 // Pre-Cache pages to improve subsequent navigation but don't making it blocking 19 // Avoid extremely large websites from using the end-users data in unexpected amount 20 cache.addAll(pageUrls); // Pre-cache all static assets by keeping them as installation dependency 21 22 return cache.addAll(staticAssets); 23 }); 24} 25 26self.addEventListener('install', function (event) { 27 // Let the new worker take over as fast as possible 28 // For quirks refer: https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#skip_the_waiting_phase 29 self.skipWaiting(); 30 event.waitUntil(preCacheResources()); 31}); 32 33function clearOldCache() { 34 return caches.keys().then(function (keys) { 35 return Promise.all(keys.filter(function (key) { 36 return key !== CACHE_NAME; 37 }).map(function (key) { 38 return caches.delete(key); 39 })); 40 }); 41} 42 43self.addEventListener('activate', function (event) { 44 // Remember to keep this step as lean as possible 45 // Only sutiable for performing stuff that can't be done while the previous worker is running 46 event.waitUntil(clearOldCache().then(function () { 47 clients.claim(); // eslint-disable-line no-undef 48 })); 49}); 50 51function isPageRequest(url) { 52 return url.origin === location.origin && pageUrls.includes(url.pathname); 53} 54 55function isNetworkOnlyRequest(url, requestMethod) { 56 // Browser extensions don't use the standard `http` and `https` protocols 57 // Refer: https://github.com/GoogleChromeLabs/sw-toolbox/issues/171 58 if (requestMethod !== 'GET' || !SW_SUPPORTED_PROTOCOL_REGEX.test(url.protocol)) { 59 return true; 60 } 61 62 const urlOrigin = url.origin; 63 const urlPathName = url.pathname; 64 const fullUrl = `${urlOrigin}${urlPathName}`; 65 66 if (networkOnlyUrls.includes(urlOrigin) || networkOnlyUrls.includes(fullUrl)) { 67 return true; 68 } 69 70 if (networkOnlyUrlsRegex.some(regex => regex.test(fullUrl))) { 71 return true; 72 } 73 74 return false; 75} 76 77function isNetworkThenCacheRequest(url, requestMethod) { 78 // Browser extensions don't use the standard `http` and `https` protocols 79 // Refer: https://github.com/GoogleChromeLabs/sw-toolbox/issues/171 80 if (requestMethod !== 'GET' || !SW_SUPPORTED_PROTOCOL_REGEX.test(url.protocol)) { 81 return true; 82 } 83 84 const urlOrigin = url.origin; 85 const urlPathName = url.pathname; 86 const fullUrl = `${urlOrigin}${urlPathName}`; 87 88 if (networkThenCacheUrls.includes(urlOrigin) || networkThenCacheUrls.includes(fullUrl)) { 89 return true; 90 } 91 92 if (networkThenCacheUrlsRegex.some(regex => regex.test(fullUrl))) { 93 return true; 94 } 95 96 return false; 97} 98 99function handleWithNetworkThenCache(event) { 100 return event.respondWith(fetch(event.request).then(function (networkResponse) { 101 if (!networkResponse.ok) { 102 return networkResponse; 103 } 104 105 return caches.open(CACHE_NAME).then(function (cache) { 106 cache.put(event.request, networkResponse.clone()); 107 return networkResponse; 108 }); 109 }).catch(function () { 110 // network failed, try to serve a cached response or offline page if there is one 111 return caches.match(event.request); 112 })); 113} 114 115function handleWithCacheThenNetwork(event) { 116 return event.respondWith(caches.open(CACHE_NAME).then(function (cache) { 117 return cache.match(event.request).then(function (response) { 118 return response || fetch(event.request).then(function (networkResponse) { 119 networkResponse.ok && cache.put(event.request, networkResponse.clone()); 120 return networkResponse; 121 }); 122 }); 123 }).catch(function (err) { 124 // TODO: respond with `offline.html` as the final fallback for page requests 125 // and use appropriate response for other cases 126 return err; 127 })); 128} 129 130function handleWithNetwork(event) { 131 return event.respondWith(fetch(event.request)); 132} 133 134function handleRequests(event) { 135 const requestURL = new URL(event.request.url); 136 137 if (isNetworkOnlyRequest(requestURL, event.request.method)) { 138 return handleWithNetwork(event); 139 } 140
141 if (isPageRequest(requestURL) || isNetworkThenCacheRequest(requestURL, event.request.method)) { 142 // To avoid serving stale content after a publish 143 // always fetch the markup from origin and use cache only when the user is offline 144 return handleWithNetworkThenCache(event); 145 } 146 147 return handleWithCacheThenNetwork(event); 148} 149 150self.addEventListener('fetch', handleRequests);
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.