chore(pwa): bump cache to v2, include variants.js, evict old caches

This commit is contained in:
Kenearos 2026-05-12 18:27:24 +02:00
parent 016ce93979
commit 49b3b53878

11
sw.js
View file

@ -1,10 +1,11 @@
const CACHE_NAME = 'dienstplan-pro-v1';
const CACHE_NAME = 'dienstplan-pro-v2';
const ASSETS = [
'./',
'./index.html',
'./styles.css',
'./app.js',
'./calculator.js',
'./variants.js',
'./holidays.js',
'./storage.js'
];
@ -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))