diff --git a/root/vite.config.ts b/root/vite.config.ts index ad2786564..3c5397585 100644 --- a/root/vite.config.ts +++ b/root/vite.config.ts @@ -94,6 +94,40 @@ export default defineConfig(({ mode }) => { }, ], }, + workbox: { + runtimeCaching: [ + { + urlPattern: ({ event }) => event.request.mode === "navigate", + handler: 'NetworkFirst', + options: { + cacheName: "navigate-cache", + fetchOptions: { + credentials: "same-origin", + }, + }, + }, + { + urlPattern: /.*\.(?:js|ts|css)/, + handler: 'NetworkFirst', + options: { + cacheName: "js-css-cache", + fetchOptions: { + credentials: "same-origin", + }, + }, + }, + { + urlPattern: /.*\.(?:png|jpg|jpeg|svg|gif|woff|woff2|eot|ttf|otf)/, + handler: "StaleWhileRevalidate", + options: { + cacheName: "image-font-cache", + fetchOptions: { + credentials: "same-origin", + }, + }, + }, + ], + }, }), ], assetsInclude: ["**/*.png", "**/*.jpg", "**/*.svg"],