added version info and reload option

This commit is contained in:
Elmar Kresse
2024-09-09 15:52:29 +02:00
parent 00009f7bfe
commit b72cdd85e1
14 changed files with 131 additions and 76 deletions

View File

@@ -1,5 +1,5 @@
import { precacheAndRoute, cleanupOutdatedCaches } from 'workbox-precaching';
import { clientsClaim } from 'workbox-core';
import { precacheAndRoute, cleanupOutdatedCaches } from "workbox-precaching";
import { clientsClaim } from "workbox-core";
self.skipWaiting();
clientsClaim();
@@ -10,19 +10,19 @@ cleanupOutdatedCaches();
precacheAndRoute(self.__WB_MANIFEST);
// Custom precaching logic for the /api/modules endpoint
self.addEventListener('install', (event) => {
self.addEventListener("install", (event) => {
event.waitUntil(
caches.open('api-modules-cache').then((cache) => {
return fetch('/api/modules')
caches.open("api-modules-cache").then((cache) => {
return fetch("/api/modules")
.then((response) => {
if (response.ok) {
return cache.put('/api/modules', response);
return cache.put("/api/modules", response);
}
throw new Error('Failed to fetch /api/modules');
throw new Error("Failed to fetch /api/modules");
})
.catch((error) => {
console.error('Precaching /api/modules failed:', error);
console.error("Precaching /api/modules failed:", error);
});
})
}),
);
});