From bb4c59f41c8d5b822ad01c14b387a9b773147c77 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sun, 3 Feb 2019 06:50:38 -0800 Subject: PWA: rename cache, update icons --- static/js/sw.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'static/js') diff --git a/static/js/sw.js b/static/js/sw.js index 12194d3..f258902 100755 --- a/static/js/sw.js +++ b/static/js/sw.js @@ -7,13 +7,16 @@ self.addEventListener('install', function(event) { var preLoad = function(){ console.log('[PWA Builder] Install Event processing'); - return caches.open('pwabuilder-offline').then(function(cache) { + return caches.open('offline').then(function(cache) { console.log('[PWA Builder] Cached index and offline page during Install'); return cache.addAll(['/blog/', '/blog', '/', '/contact', '/resume']); }); }; self.addEventListener('fetch', function(event) { + if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin') { + return; + } console.log('[PWA Builder] The service worker is serving the asset.'); event.respondWith(checkResponse(event.request).catch(function() { return returnFromCache(event.request); @@ -34,16 +37,16 @@ var checkResponse = function(request){ }; var addToCache = function(request){ - return caches.open('pwabuilder-offline').then(function (cache) { + return caches.open('offline').then(function (cache) { return fetch(request).then(function (response) { - console.log('[PWA Builder] add page to offline'+response.url); + console.log('[PWA Builder] add page to offline: ' + response.url); return cache.put(request, response); }); }); }; var returnFromCache = function(request){ - return caches.open('pwabuilder-offline').then(function (cache) { + return caches.open('offline').then(function (cache) { return cache.match(request).then(function (matching) { if(!matching || matching.status == 404) { return cache.match('offline.html'); -- cgit v1.2.3