fix: prevent stale cache issues with proper no-cache headers

- 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 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2025-12-24 10:43:25 -05:00
parent 3ff8d5c692
commit bba1f7955a
2 changed files with 29 additions and 1 deletions

View File

@ -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";

View File

@ -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.)