fix: nginx proxy URI, SW cache noms uniques, sw.js no-cache

This commit is contained in:
Claude
2026-05-01 07:51:13 +02:00
parent 5de20a2fcf
commit 6741f9fa75
2 changed files with 24 additions and 7 deletions
+18 -3
View File
@@ -17,8 +17,23 @@ server {
application/javascript application/json application/javascript application/json
image/svg+xml; image/svg+xml;
# ── PWA : cache long sur les assets hasheés ─────────────── # ── Service Worker — jamais mis en cache (sinon l'ancien SW tourne après déploiement)
location ~* \.(js|css|woff2?|png|svg|ico|webmanifest)$ { location = /sw.js {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
expires 0;
try_files $uri =404;
}
# ── Manifeste PWA — pas de cache long (doit se mettre à jour)
location ~* \.webmanifest$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
expires 0;
try_files $uri =404;
}
# ── PWA : cache long sur les assets hashés par Vite ──────────
location ~* \.(js|css|woff2?|png|svg|ico)$ {
expires 1y; expires 1y;
add_header Cache-Control "public, immutable"; add_header Cache-Control "public, immutable";
try_files $uri =404; try_files $uri =404;
@@ -27,7 +42,7 @@ server {
# ── API → backend (service Docker interne) ──────────────── # ── API → backend (service Docker interne) ────────────────
location /api/ { location /api/ {
set $upstream_backend http://notesfrais-backend:3001; set $upstream_backend http://notesfrais-backend:3001;
proxy_pass $upstream_backend/api/; proxy_pass $upstream_backend;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Host $host; proxy_set_header Host $host;
+6 -4
View File
@@ -26,13 +26,15 @@ export default defineConfig({
}, },
workbox: { workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'], globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
cleanupOutdatedCaches: true,
runtimeCaching: [ runtimeCaching: [
{ {
// Cache API responses (stale-while-revalidate pour les listes) // Network-first pour les listes (évite de servir un cache vide)
urlPattern: /^\/api\/(?:companies|categories)/, urlPattern: /^\/api\/(?:companies|categories)/,
handler: 'StaleWhileRevalidate', handler: 'NetworkFirst',
options: { options: {
cacheName: 'api-static', cacheName: 'notesfrais-api-static',
networkTimeoutSeconds: 8,
expiration: { maxEntries: 20, maxAgeSeconds: 60 * 60 }, expiration: { maxEntries: 20, maxAgeSeconds: 60 * 60 },
}, },
}, },
@@ -41,7 +43,7 @@ export default defineConfig({
urlPattern: /^\/api\/invoices/, urlPattern: /^\/api\/invoices/,
handler: 'NetworkFirst', handler: 'NetworkFirst',
options: { options: {
cacheName: 'api-invoices', cacheName: 'notesfrais-api-invoices',
networkTimeoutSeconds: 8, networkTimeoutSeconds: 8,
expiration: { maxEntries: 100, maxAgeSeconds: 24 * 60 * 60 }, expiration: { maxEntries: 100, maxAgeSeconds: 24 * 60 * 60 },
}, },