chore(pwa): bump cache to v3, precache image-import.js, evict old caches on activate
This commit is contained in:
parent
7839fd67d7
commit
2e05067ce0
1 changed files with 11 additions and 2 deletions
13
sw.js
13
sw.js
|
|
@ -1,4 +1,4 @@
|
|||
const CACHE_NAME = 'dienstplan-pro-v1';
|
||||
const CACHE_NAME = 'dienstplan-pro-v3';
|
||||
const ASSETS = [
|
||||
'./',
|
||||
'./index.html',
|
||||
|
|
@ -6,7 +6,8 @@ const ASSETS = [
|
|||
'./app.js',
|
||||
'./calculator.js',
|
||||
'./holidays.js',
|
||||
'./storage.js'
|
||||
'./storage.js',
|
||||
'./image-import.js'
|
||||
];
|
||||
|
||||
self.addEventListener('install', (e) => {
|
||||
|
|
@ -15,6 +16,14 @@ self.addEventListener('install', (e) => {
|
|||
);
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (e) => {
|
||||
e.waitUntil(
|
||||
caches.keys().then((keys) =>
|
||||
Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (e) => {
|
||||
e.respondWith(
|
||||
caches.match(e.request).then((response) => response || fetch(e.request))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue