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
image/svg+xml;
# ── PWA : cache long sur les assets hasheés ───────────────
location ~* \.(js|css|woff2?|png|svg|ico|webmanifest)$ {
# ── Service Worker — jamais mis en cache (sinon l'ancien SW tourne après déploiement)
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;
add_header Cache-Control "public, immutable";
try_files $uri =404;
@@ -27,7 +42,7 @@ server {
# ── API → backend (service Docker interne) ────────────────
location /api/ {
set $upstream_backend http://notesfrais-backend:3001;
proxy_pass $upstream_backend/api/;
proxy_pass $upstream_backend;
proxy_http_version 1.1;
proxy_set_header Host $host;
+6 -4
View File
@@ -26,13 +26,15 @@ export default defineConfig({
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
cleanupOutdatedCaches: true,
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)/,
handler: 'StaleWhileRevalidate',
handler: 'NetworkFirst',
options: {
cacheName: 'api-static',
cacheName: 'notesfrais-api-static',
networkTimeoutSeconds: 8,
expiration: { maxEntries: 20, maxAgeSeconds: 60 * 60 },
},
},
@@ -41,7 +43,7 @@ export default defineConfig({
urlPattern: /^\/api\/invoices/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-invoices',
cacheName: 'notesfrais-api-invoices',
networkTimeoutSeconds: 8,
expiration: { maxEntries: 100, maxAgeSeconds: 24 * 60 * 60 },
},