change mailbox behaviour to use reception confirmations

This commit is contained in:
marlon-erler
2026-03-31 22:02:13 +00:00
parent 959dc4d288
commit ec020e6358
21 changed files with 2772 additions and 2476 deletions
+18 -18
View File
@@ -1,38 +1,38 @@
const CACHE_VERSION = "v1";
async function handleRequest(event) {
const responsePromise = getResponse(event);
event.respondWith(responsePromise);
const responsePromise = getResponse(event);
event.respondWith(responsePromise);
}
async function getResponse(event) {
try {
return await fetchAndCache(event);
} catch {
return await getFromCache(event);
}
try {
return await fetchAndCache(event);
} catch {
return await getFromCache(event);
}
}
async function fetchAndCache(event) {
const request = event.request;
const request = event.request;
const response = await fetch(request);
const response = await fetch(request);
const cache = await caches.open(CACHE_VERSION);
await cache.put(request, response.clone());
const cache = await caches.open(CACHE_VERSION);
await cache.put(request, response.clone());
return response;
return response;
}
async function getFromCache(event) {
const request = event.request;
const request = event.request;
const cache = await caches.open(CACHE_VERSION);
const response = await cache.match(request);
const cache = await caches.open(CACHE_VERSION);
const response = await cache.match(request);
return response;
return response;
}
self.addEventListener("fetch", (event) => {
handleRequest(event);
});
handleRequest(event);
});