33 lines
701 B
JavaScript
33 lines
701 B
JavaScript
const CACHE_NAME = 'dienstplan-pro-v5';
|
|
const ASSETS = [
|
|
'./',
|
|
'./index.html',
|
|
'./styles.css',
|
|
'./app.js',
|
|
'./calculator.js',
|
|
'./variants.js',
|
|
'./holidays.js',
|
|
'./storage.js',
|
|
'./sync.js',
|
|
'./image-import.js'
|
|
];
|
|
|
|
self.addEventListener('install', (e) => {
|
|
e.waitUntil(
|
|
caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS))
|
|
);
|
|
});
|
|
|
|
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))
|
|
);
|
|
});
|