forked from cadey/xesite
le bump
This commit is contained in:
parent
4ea63cbc2e
commit
4c7f3036ff
|
@ -2526,7 +2526,7 @@ checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xesite"
|
name = "xesite"
|
||||||
version = "2.2.0"
|
version = "2.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfcache",
|
"cfcache",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
@ -2548,7 +2548,7 @@ dependencies = [
|
||||||
"pfacts",
|
"pfacts",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
"rand 0.8.3",
|
"rand 0.7.3",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"ructe",
|
"ructe",
|
||||||
"sdnotify",
|
"sdnotify",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "xesite"
|
name = "xesite"
|
||||||
version = "2.2.0"
|
version = "2.2.1"
|
||||||
authors = ["Christine Dodrill <me@christine.website>"]
|
authors = ["Christine Dodrill <me@christine.website>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
build = "src/build.rs"
|
build = "src/build.rs"
|
||||||
|
|
|
@ -1,44 +1,44 @@
|
||||||
//This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
|
//This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
|
||||||
|
|
||||||
//Install stage sets up the offline page in the cache and opens a new cache
|
//Install stage sets up the offline page in the cache and opens a new cache
|
||||||
self.addEventListener('install', function(event) {
|
self.addEventListener('install', function (event) {
|
||||||
event.waitUntil(preLoad());
|
event.waitUntil(preLoad());
|
||||||
});
|
});
|
||||||
|
|
||||||
const cacheName = "cache-xesite-2.0.0";
|
const cacheName = "cache-xesite-2.1.1";
|
||||||
|
|
||||||
var preLoad = function(){
|
var preLoad = function () {
|
||||||
console.log('[PWA Builder] Install Event processing');
|
console.log('[PWA Builder] Install Event processing');
|
||||||
return caches.open(cacheName).then(function(cache) {
|
return caches.open(cacheName).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', '/talks', '/gallery', '/signalboost']);
|
return cache.addAll(['/blog/', '/blog', '/', '/contact', '/resume', '/talks', '/gallery', '/signalboost']);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
self.addEventListener('fetch', function(event) {
|
self.addEventListener('fetch', function (event) {
|
||||||
if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin') {
|
if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin') {
|
||||||
return;
|
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);
|
||||||
}));
|
}));
|
||||||
event.waitUntil(addToCache(event.request));
|
event.waitUntil(addToCache(event.request));
|
||||||
});
|
});
|
||||||
|
|
||||||
var checkResponse = function(request){
|
var checkResponse = function (request) {
|
||||||
return new Promise(function(fulfill, reject) {
|
return new Promise(function (fulfill, reject) {
|
||||||
fetch(request).then(function(response){
|
fetch(request).then(function (response) {
|
||||||
if(response.status !== 404) {
|
if (response.status !== 404) {
|
||||||
fulfill(response);
|
fulfill(response);
|
||||||
} else {
|
} else {
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
}, reject);
|
}, reject);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var addToCache = function(request){
|
var addToCache = function (request) {
|
||||||
return caches.open(cacheName).then(function (cache) {
|
return caches.open(cacheName).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);
|
||||||
|
@ -47,14 +47,14 @@ var addToCache = function(request){
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var returnFromCache = function(request){
|
var returnFromCache = function (request) {
|
||||||
return caches.open(cacheName).then(function (cache) {
|
return caches.open(cacheName).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');
|
||||||
} else {
|
} else {
|
||||||
return matching;
|
return matching;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue