error page, sw

This commit is contained in:
Martti Malmi
2024-01-10 14:07:44 +02:00
parent 7be4b0bd18
commit 90b15ee668
3 changed files with 31 additions and 11 deletions

View File

@ -15,6 +15,23 @@ import { formatShort } from "@/Utils/Number";
precacheAndRoute(self.__WB_MANIFEST);
clientsClaim();
// cache everything in current domain /assets because precache doesn't seem to include everything
registerRoute(
({ url }) => url.origin === location.origin && url.pathname.startsWith("/assets"),
new StaleWhileRevalidate({
cacheName: "assets-cache",
plugins: [
new ExpirationPlugin({
maxEntries: 200,
matchOptions: {
ignoreVary: true,
}
}),
],
}),
);
registerRoute(
({ url }) => url.pathname.endsWith("/.well-known/nostr.json"),
new StaleWhileRevalidate({
@ -32,13 +49,16 @@ registerRoute(
plugins: [
new ExpirationPlugin({
maxEntries: 200,
matchOptions: {
ignoreVary: true,
}
}),
],
}),
);
registerRoute(
({ url }) => url.pathname.endsWith("api/v1/preview"),
({ url }) => url.origin === "https://api.snort.social" && url.pathname.startsWith("/api/v1/preview"),
new StaleWhileRevalidate({
cacheName: "preview-cache",
plugins: [new ExpirationPlugin({ maxAgeSeconds: 4 * 60 * 60 })],