chore(pwa): bump cache to v3, precache image-import.js, evict old caches on activate

This commit is contained in:
Kenearos 2026-05-12 18:25:16 +02:00
parent 7839fd67d7
commit 2e05067ce0

13
sw.js
View file

@ -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))