Skip to content

Commit 25f3c64

Browse files
committed
add runtimeCaching in vitePWA
1 parent 95b81c4 commit 25f3c64

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Diff for: vite.config.mts

+24
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,30 @@ export default defineConfig(({ mode }) => {
214214
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
215215
cleanupOutdatedCaches: true,
216216
maximumFileSizeToCacheInBytes: 10000000,
217+
runtimeCaching: [
218+
{
219+
urlPattern: ({ request }) => request.destination === 'style',
220+
handler: 'NetworkFirst',
221+
options: {
222+
cacheName: 'css-cache',
223+
expiration: {
224+
maxEntries: 30,
225+
maxAgeSeconds: 60 * 60 * 24 * 15,
226+
},
227+
},
228+
},
229+
{
230+
urlPattern: ({ request }) => request.destination === 'script',
231+
handler: 'NetworkFirst',
232+
options: {
233+
cacheName: 'js-cache',
234+
expiration: {
235+
maxEntries: 30,
236+
maxAgeSeconds: 60 * 60 * 24 * 15,
237+
},
238+
},
239+
},
240+
],
217241
},
218242
manifest: {
219243
short_name: 'Devtron',

0 commit comments

Comments
 (0)