From 87f5753804f2cf531190046ab538ab6982e1a39a Mon Sep 17 00:00:00 2001 From: "khalid@traclabs.com" Date: Sun, 24 May 2026 11:06:10 -0500 Subject: [PATCH] Fix uploads and stickers caching rules --- vite.config.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/vite.config.js b/vite.config.js index b9b89e2..165a216 100644 --- a/vite.config.js +++ b/vite.config.js @@ -152,8 +152,17 @@ export default defineConfig({ cacheableResponse: { statuses: [0, 200] }, }, }, + // Same-origin path rules below use the full-URL form + // `^https?://[^/]+//` rather than a path-only `^//`. + // Workbox matches RegExp urlPatterns against the request's + // full href (e.g. "https://example.com/stickers/cat.png"), + // so a regex anchored with `^//` would require the URL + // string to literally START with that path — which it never + // does, since the URL always starts with the scheme. The full + // form anchors at the scheme and consumes the origin + // explicitly, then matches the intended pathname. { - urlPattern: /^\/uploads\/.*/i, + urlPattern: /^https?:\/\/[^/]+\/uploads\//i, handler: 'CacheFirst', options: { cacheName: 'uploaded-images', @@ -161,7 +170,7 @@ export default defineConfig({ }, }, { - urlPattern: /^\/api\/.*/i, + urlPattern: /^https?:\/\/[^/]+\/api\//i, handler: 'NetworkFirst', options: { cacheName: 'api-responses', @@ -199,7 +208,7 @@ export default defineConfig({ // Browser storage quotas (typically tens to hundreds of MB) // remain the ultimate ceiling — maxEntries just stops // Workbox from evicting earlier than the browser would. - urlPattern: /^\/stickers\/.*/i, + urlPattern: /^https?:\/\/[^/]+\/stickers\//i, handler: 'CacheFirst', options: { cacheName: 'sticker-library',