Frontend: Remove old service worker caches
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
6297422515
commit
52bbcb4489
@ -1,7 +1,5 @@
|
|||||||
/*Overrides*/
|
/*Overrides*/
|
||||||
.titleimg{
|
.titleimg{
|
||||||
height: 200px;
|
|
||||||
width: 234.38px;
|
|
||||||
padding-bottom: 0px;
|
padding-bottom: 0px;
|
||||||
}
|
}
|
||||||
.small-lookup-box{
|
.small-lookup-box{
|
||||||
|
21
static/sw.js
21
static/sw.js
@ -1,16 +1,16 @@
|
|||||||
/* Service Worker */
|
/* Service Worker */
|
||||||
|
|
||||||
const appVersion = "0.0.1-dev"
|
const appVersion = "0.0.1-dev"
|
||||||
const cacheName = "owlboard0-0-1-dev"
|
const cacheName = `owlboard-${appVersion}`
|
||||||
|
const cacheIDs = [cacheName]
|
||||||
const cacheFiles = [
|
const cacheFiles = [
|
||||||
"/404.html",
|
"/404.html",
|
||||||
"/board.html",
|
|
||||||
"/conn-err.html",
|
"/conn-err.html",
|
||||||
"/find-code.html",
|
|
||||||
"/help.html",
|
"/help.html",
|
||||||
"/",
|
"/",
|
||||||
"/issue.html",
|
"/issue.html",
|
||||||
"/settings.html",
|
"/settings.html",
|
||||||
|
"/manifest.json",
|
||||||
"/styles/fonts/firamono/firamono-500.woff2",
|
"/styles/fonts/firamono/firamono-500.woff2",
|
||||||
"/styles/fonts/firamono/firamono-regular.woff2",
|
"/styles/fonts/firamono/firamono-regular.woff2",
|
||||||
"/styles/fonts/urwgothic/urwgothic.woff2",
|
"/styles/fonts/urwgothic/urwgothic.woff2",
|
||||||
@ -50,13 +50,24 @@ self.addEventListener("install", (e) => {
|
|||||||
e.respondWith(
|
e.respondWith(
|
||||||
(async () => {
|
(async () => {
|
||||||
const r = await caches.match(e.request);
|
const r = await caches.match(e.request);
|
||||||
console.log(`[Service Worker] Fetching resource: ${e.request.url}`);
|
|
||||||
if (r) {
|
if (r) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
const response = await fetch(e.request);
|
const response = await fetch(e.request);
|
||||||
console.log(`[Service Worker] Fetching from server: ${e.request.url}`);
|
console.log(`[Service Worker] Not cached - fetching from server: ${e.request.url}`);
|
||||||
return response;
|
return response;
|
||||||
})()
|
})()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.addEventListener('activate', function (event) {
|
||||||
|
event.waitUntil(caches.keys().then(function (keys) {
|
||||||
|
return Promise.all(keys.filter(function (key) {
|
||||||
|
return !cacheIDs.includes(key);
|
||||||
|
}).map(function (key) {
|
||||||
|
return caches.delete(key);
|
||||||
|
}));
|
||||||
|
}).then(function () {
|
||||||
|
return self.clients.claim();
|
||||||
|
}));
|
||||||
|
});
|
Reference in New Issue
Block a user