From 2bcb92a296fef612bca5e0dedf8417f437a583ad Mon Sep 17 00:00:00 2001 From: Marcel Mraz Date: Tue, 20 Aug 2024 17:42:35 +0200 Subject: [PATCH] Remove wasm from pre-cache, but cache first in runtime --- excalidraw-app/vite.config.mts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/excalidraw-app/vite.config.mts b/excalidraw-app/vite.config.mts index 0e84fa537d..e8617f396b 100644 --- a/excalidraw-app/vite.config.mts +++ b/excalidraw-app/vite.config.mts @@ -73,8 +73,8 @@ export default defineConfig({ }, workbox: { - // Don't push fonts and locales to app precache - globIgnores: ["fonts.css", "**/locales/**", "service-worker.js"], + // Don't push fonts, locales and wasm to app precache + globIgnores: ["fonts.css", "**/locales/**", "service-worker.js", "**/*.wasm-*.js"], runtimeCaching: [ { urlPattern: new RegExp("/.+.(ttf|woff2|otf)"), @@ -108,6 +108,17 @@ export default defineConfig({ }, }, }, + { + urlPattern: new RegExp(".wasm-.+.js"), + handler: "CacheFirst", + options: { + cacheName: "wasm", + expiration: { + maxEntries: 50, + maxAgeSeconds: 60 * 60 * 24 * 90, // <== 90 days + }, + }, + }, ], }, manifest: {