Skip to content

Commit 179ec72

Browse files
authored
Update service workers config (#1425)
Remove html from any caching
1 parent 89a68cd commit 179ec72

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

astro.config.mjs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,27 @@ export default defineConfig({
153153
mdx(),
154154
svelte(),
155155
serviceWorker({
156-
workbox: { inlineWorkboxRuntime: true },
156+
workbox: {
157+
inlineWorkboxRuntime: true,
158+
runtimeCaching: [
159+
{
160+
urlPattern:
161+
/\.(?:js|css|json|png|jpg|jpeg|svg|woff2?|ttf|eot|gif)$/,
162+
handler: "CacheFirst",
163+
options: {
164+
cacheName: "assets-cache",
165+
expiration: {
166+
maxEntries: 100,
167+
maxAgeSeconds: 60 * 60 * 1, // 1h
168+
},
169+
},
170+
},
171+
{
172+
urlPattern: /\.html$/,
173+
handler: "NetworkOnly", // ⛔ Don't cache HTML
174+
},
175+
],
176+
},
157177
}),
158178
...(fastBuild
159179
? []

0 commit comments

Comments
 (0)