This commit is contained in:
Martti Malmi
2024-01-09 22:35:57 +02:00
parent 91f0afdb89
commit cf6b431d73
4 changed files with 15 additions and 15 deletions

View File

@ -31,12 +31,20 @@ registerRoute(
cacheName: "image-cache",
plugins: [
new ExpirationPlugin({
maxEntries: 100,
maxEntries: 200,
}),
],
}),
);
registerRoute(
({ url }) => url.pathname.endsWith("api/v1/preview"),
new StaleWhileRevalidate({
cacheName: "preview-cache",
plugins: [new ExpirationPlugin({ maxAgeSeconds: 4 * 60 * 60 })],
}),
);
self.addEventListener("message", event => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();