From bba1f7955a3d17520e2d6ff986b6088d11442485 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Wed, 24 Dec 2025 10:43:25 -0500 Subject: [PATCH] fix: prevent stale cache issues with proper no-cache headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add no-cache headers for index.html, sw.js, registerSW.js, manifest.webmanifest - Add skipWaiting and clientsClaim to workbox config for immediate SW updates - This ensures new deployments are picked up immediately without manual cache clearing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- nginx.conf | 27 ++++++++++++++++++++++++++- vite.config.ts | 3 +++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/nginx.conf b/nginx.conf index fb5b259..6577200 100644 --- a/nginx.conf +++ b/nginx.conf @@ -18,7 +18,32 @@ server { add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; - # Cache static assets + # NEVER cache index.html and service worker - always fetch fresh + location = /index.html { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + add_header Expires "0"; + } + + location = /sw.js { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + add_header Expires "0"; + } + + location = /registerSW.js { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + add_header Expires "0"; + } + + location = /manifest.webmanifest { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + add_header Expires "0"; + } + + # Cache static assets with hashed filenames (immutable) location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; diff --git a/vite.config.ts b/vite.config.ts index b54d19f..0d94e02 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -34,6 +34,9 @@ export default defineConfig(({ mode }) => { registerType: 'autoUpdate', injectRegister: 'auto', workbox: { + // Force the service worker to take control immediately + skipWaiting: true, + clientsClaim: true, // Cache all static assets globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2,wasm}'], // Increase the limit for large chunks (Board is ~8MB with tldraw, automerge, etc.)