Fix uploads and stickers caching rules

This commit is contained in:
khalid@traclabs.com
2026-05-24 11:06:10 -05:00
parent e4e9459c86
commit 87f5753804

View File

@@ -152,8 +152,17 @@ export default defineConfig({
cacheableResponse: { statuses: [0, 200] },
},
},
// Same-origin path rules below use the full-URL form
// `^https?://[^/]+/<path>/` rather than a path-only `^/<path>/`.
// Workbox matches RegExp urlPatterns against the request's
// full href (e.g. "https://example.com/stickers/cat.png"),
// so a regex anchored with `^/<path>/` 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',