diff options
| author | Christine Dodrill <me@christine.website> | 2018-11-13 07:44:45 -0800 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-11-13 07:44:51 -0800 |
| commit | 2453be38178be967d0c3330af16a373a219a9ab5 (patch) | |
| tree | 98b00e3a07b6a34ccde80224df1ddf21a5aeac29 /static | |
| parent | e245d89daa6dffc441be07dcb81b985397446378 (diff) | |
| download | xesite-2453be38178be967d0c3330af16a373a219a9ab5.tar.xz xesite-2453be38178be967d0c3330af16a373a219a9ab5.zip | |
update service worker to hack things
Diffstat (limited to 'static')
| -rwxr-xr-x | static/js/sw.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/static/js/sw.js b/static/js/sw.js index 4b3b1e2..12194d3 100755 --- a/static/js/sw.js +++ b/static/js/sw.js @@ -9,15 +9,15 @@ var preLoad = function(){ console.log('[PWA Builder] Install Event processing');
return caches.open('pwabuilder-offline').then(function(cache) {
console.log('[PWA Builder] Cached index and offline page during Install');
- return cache.addAll(['/offline.html', '/index.html']);
+ return cache.addAll(['/blog/', '/blog', '/', '/contact', '/resume']);
});
-}
+};
self.addEventListener('fetch', function(event) {
console.log('[PWA Builder] The service worker is serving the asset.');
event.respondWith(checkResponse(event.request).catch(function() {
- return returnFromCache(event.request)}
- ));
+ return returnFromCache(event.request);
+ }));
event.waitUntil(addToCache(event.request));
});
@@ -25,18 +25,18 @@ var checkResponse = function(request){ return new Promise(function(fulfill, reject) {
fetch(request).then(function(response){
if(response.status !== 404) {
- fulfill(response)
+ fulfill(response);
} else {
- reject()
+ reject();
}
- }, reject)
+ }, reject);
});
};
var addToCache = function(request){
return caches.open('pwabuilder-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);
});
});
@@ -46,9 +46,9 @@ var returnFromCache = function(request){ return caches.open('pwabuilder-offline').then(function (cache) {
return cache.match(request).then(function (matching) {
if(!matching || matching.status == 404) {
- return cache.match('offline.html')
+ return cache.match('offline.html');
} else {
- return matching
+ return matching;
}
});
});
|
