sw.js hinzugefügt
This commit is contained in:
1 parent
9698646db1
commit
e706533273
1 file changed
+34
@@ -0,0 +1,34 @@
|
||||
// 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))
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user