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