diff --git a/src/app/serwist/[path]/route.ts b/src/app/serwist/[path]/route.ts index ec8c523..7772aae 100644 --- a/src/app/serwist/[path]/route.ts +++ b/src/app/serwist/[path]/route.ts @@ -15,7 +15,7 @@ import { createSerwistRoute } from "@serwist/turbopack"; const revision = spawnSync("git", ["rev-parse", "HEAD"], { encoding: "utf-8" }).stdout ?? crypto.randomUUID(); export const { dynamic, dynamicParams, revalidate, generateStaticParams, GET } = createSerwistRoute({ - additionalPrecacheEntries: [{ url: "/~offline", revision }], + additionalPrecacheEntries: [{ url: "/", revision }], swSrc: "src/app/sw.ts", // nextConfig, // If set to `false`, Serwist will attempt to use `esbuild-wasm`. diff --git a/src/app/sw.ts b/src/app/sw.ts index 5eef8d9..fd6fe08 100644 --- a/src/app/sw.ts +++ b/src/app/sw.ts @@ -28,7 +28,15 @@ const serwist = new Serwist({ skipWaiting: true, clientsClaim: true, navigationPreload: true, - runtimeCaching: defaultCache, + runtimeCaching: [ + ...defaultCache, + { + matcher: ({ url }) => url.hostname.includes('tile.openstreetmap.org') || url.pathname.includes('/tiles/'), + handler: new CacheFirst({ + cacheName: 'excalibur-offline-map-tiles-v1', + }), + }, + ], fallbacks: { entries: [ {