-
Notifications
You must be signed in to change notification settings - Fork 10
/
sw.min.js
2 lines (2 loc) · 1.55 KB
/
sw.min.js
1
2
var cacheName="shimansky.biz-offline-v1602190349",indexPage="index.html",offlinePages=[indexPage];function updateStaticCache(){return caches.open(cacheName).then(function(e){return e.addAll(offlinePages)})}function clearOldCaches(){return caches.keys().then(function(e){return Promise.all(e.filter(function(e){return 0!==e.indexOf(cacheName)}).map(function(e){return caches.delete(e)}))})}function isHtmlRequest(e){return-1!==e.headers.get("Accept").indexOf("text/html")}function isCachableResponse(e){return e&&e.ok}self.addEventListener("install",function(e){e.waitUntil(updateStaticCache().then(function () {return self.skipWaiting()}))}),self.addEventListener("activate",function(e){e.waitUntil(clearOldCaches().then(function () {return self.clients.claim()}))}),self.addEventListener("fetch",function(e){var t=e.request;if("GET"!==t.method)return!navigator.onLine&&isHtmlRequest(t)?e.respondWith(caches.match(indexPage)):void 0;if(isHtmlRequest(t))e.respondWith(fetch(t).then(function(e){if(isCachableResponse(e)){var n=e.clone();caches.open(cacheName).then(function(e){return e.put(t,n)})}return e}).catch(function () {return caches.match(t).then(function(e){return e||"navigate"!==t.mode?e:caches.match(indexPage)})}));else{if("only-if-cached"===e.request.cache&&"same-origin"!==e.request.mode)return;e.respondWith(caches.match(t).then(function(e){return e||fetch(t,{credentials:"include",redirect:"follow"}).then(function(e){if(isCachableResponse(e)){var n=e.clone();caches.open(cacheName).then(function(e){return e.put(t,n)})}return e})}))}});
//# sourceMappingURL=sw.min.js.map