feat: add CacheFirst SW rule for attachment images

Attachment images are immutable (UUID-based), so CacheFirst is ideal.
Previously-viewed images remain available offline even after blob URLs
expire. Rule placed before general NetworkFirst API rule to match first.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Frederic Cabassut
2026-03-08 22:37:50 +01:00
committed by Fred Cabassut
co-authored by Claude Opus 4.6
parent c3aa81949c
commit 087d7a48e6
+8
View File
@@ -27,6 +27,14 @@ export default defineConfig({
globPatterns: ['client/**/*.{js,css,ico,png,svg,webp,woff,woff2}'],
navigateFallback: '/',
runtimeCaching: [
{
urlPattern: /\/api\/notes\/.*\/attachments\?attachmentId=/,
handler: 'CacheFirst',
options: {
cacheName: 'attachment-cache',
expiration: { maxEntries: 200, maxAgeSeconds: 365 * 24 * 60 * 60 }
}
},
{
urlPattern: /^https?:\/\/.*\/api\//,
handler: 'NetworkFirst',