From 8b9618d65f8c12a7af30661365b8da08179b72ec Mon Sep 17 00:00:00 2001 From: Frederic Cabassut Date: Sun, 8 Mar 2026 21:25:41 +0100 Subject: [PATCH] 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 --- vite.config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index dba91aa..2fb0fca 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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',