aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-02-03 06:50:38 -0800
committerChristine Dodrill <me@christine.website>2019-02-03 06:50:38 -0800
commitbb4c59f41c8d5b822ad01c14b387a9b773147c77 (patch)
tree058301db4f4ce8c4718c17034cef8c23665387eb /static
parentbfb5327e33666244010407841f4f9fdf823a5fb2 (diff)
downloadxesite-bb4c59f41c8d5b822ad01c14b387a9b773147c77.tar.xz
xesite-bb4c59f41c8d5b822ad01c14b387a9b773147c77.zip
PWA: rename cache, update icons
Diffstat (limited to 'static')
-rwxr-xr-xstatic/js/sw.js11
-rw-r--r--static/manifest.json4
2 files changed, 9 insertions, 6 deletions
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');
diff --git a/static/manifest.json b/static/manifest.json
index f529a86..3d11b2e 100644
--- a/static/manifest.json
+++ b/static/manifest.json
@@ -5,7 +5,7 @@
"background_color": "#fa99ca",
"display": "standalone",
"scope": "/",
- "start_url": "https://christine.website/",
+ "start_url": "/",
"description": "Blog and Resume for Christine Dodrill",
"orientation": "any",
"icons": [
@@ -52,6 +52,6 @@
{
"src": "/static/favicon/android-launchericon-512-512.png",
"sizes": "512x512"
- },
+ }
]
}