PWA: rename cache, update icons
This commit is contained in:
parent
bfb5327e33
commit
bb4c59f41c
|
@ -7,13 +7,16 @@ self.addEventListener('install', function(event) {
|
||||||
|
|
||||||
var preLoad = function(){
|
var preLoad = function(){
|
||||||
console.log('[PWA Builder] Install Event processing');
|
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');
|
console.log('[PWA Builder] Cached index and offline page during Install');
|
||||||
return cache.addAll(['/blog/', '/blog', '/', '/contact', '/resume']);
|
return cache.addAll(['/blog/', '/blog', '/', '/contact', '/resume']);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
self.addEventListener('fetch', function(event) {
|
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.');
|
console.log('[PWA Builder] The service worker is serving the asset.');
|
||||||
event.respondWith(checkResponse(event.request).catch(function() {
|
event.respondWith(checkResponse(event.request).catch(function() {
|
||||||
return returnFromCache(event.request);
|
return returnFromCache(event.request);
|
||||||
|
@ -34,16 +37,16 @@ var checkResponse = function(request){
|
||||||
};
|
};
|
||||||
|
|
||||||
var addToCache = 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) {
|
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);
|
return cache.put(request, response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var returnFromCache = function(request){
|
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) {
|
return cache.match(request).then(function (matching) {
|
||||||
if(!matching || matching.status == 404) {
|
if(!matching || matching.status == 404) {
|
||||||
return cache.match('offline.html');
|
return cache.match('offline.html');
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"background_color": "#fa99ca",
|
"background_color": "#fa99ca",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"scope": "/",
|
"scope": "/",
|
||||||
"start_url": "https://christine.website/",
|
"start_url": "/",
|
||||||
"description": "Blog and Resume for Christine Dodrill",
|
"description": "Blog and Resume for Christine Dodrill",
|
||||||
"orientation": "any",
|
"orientation": "any",
|
||||||
"icons": [
|
"icons": [
|
||||||
|
@ -52,6 +52,6 @@
|
||||||
{
|
{
|
||||||
"src": "/static/favicon/android-launchericon-512-512.png",
|
"src": "/static/favicon/android-launchericon-512-512.png",
|
||||||
"sizes": "512x512"
|
"sizes": "512x512"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue