34 lines
758 B
JavaScript
34 lines
758 B
JavaScript
// Service Worker: Offline-Fähigkeit für die PWA
|
|
const CACHE_NAME = "hunde-business-v1";
|
|
const ASSETS = [
|
|
"./",
|
|
"./index.html",
|
|
"./style.css",
|
|
"./app.js",
|
|
"./db.js",
|
|
"./config.js",
|
|
"./manifest.webmanifest",
|
|
"./icons/icon.svg",
|
|
];
|
|
|
|
self.addEventListener("install", (e) => {
|
|
e.waitUntil(
|
|
caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS))
|
|
);
|
|
self.skipWaiting();
|
|
});
|
|
|
|
self.addEventListener("activate", (e) => {
|
|
e.waitUntil(
|
|
caches.keys().then((keys) =>
|
|
Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
|
|
)
|
|
);
|
|
self.clients.claim();
|
|
});
|
|
|
|
self.addEventListener("fetch", (e) => {
|
|
e.respondWith(
|
|
caches.match(e.request).then((cached) => cached || fetch(e.request))
|
|
);
|
|
}); |