Fix uploads and stickers caching rules
This commit is contained in:
@@ -152,8 +152,17 @@ export default defineConfig({
|
|||||||
cacheableResponse: { statuses: [0, 200] },
|
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',
|
handler: 'CacheFirst',
|
||||||
options: {
|
options: {
|
||||||
cacheName: 'uploaded-images',
|
cacheName: 'uploaded-images',
|
||||||
@@ -161,7 +170,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
urlPattern: /^\/api\/.*/i,
|
urlPattern: /^https?:\/\/[^/]+\/api\//i,
|
||||||
handler: 'NetworkFirst',
|
handler: 'NetworkFirst',
|
||||||
options: {
|
options: {
|
||||||
cacheName: 'api-responses',
|
cacheName: 'api-responses',
|
||||||
@@ -199,7 +208,7 @@ export default defineConfig({
|
|||||||
// Browser storage quotas (typically tens to hundreds of MB)
|
// Browser storage quotas (typically tens to hundreds of MB)
|
||||||
// remain the ultimate ceiling — maxEntries just stops
|
// remain the ultimate ceiling — maxEntries just stops
|
||||||
// Workbox from evicting earlier than the browser would.
|
// Workbox from evicting earlier than the browser would.
|
||||||
urlPattern: /^\/stickers\/.*/i,
|
urlPattern: /^https?:\/\/[^/]+\/stickers\//i,
|
||||||
handler: 'CacheFirst',
|
handler: 'CacheFirst',
|
||||||
options: {
|
options: {
|
||||||
cacheName: 'sticker-library',
|
cacheName: 'sticker-library',
|
||||||
|
|||||||
Reference in New Issue
Block a user