fix: Implement Network-First SW strategy, no-cache headers in Nginx for index.html/sw.js, and auto 401 token cleanup to fix post-redeploy stale cache issues

This commit is contained in:
Richard
2026-07-31 11:23:49 +02:00
parent 2403f1313f
commit ac71b38823
7 changed files with 83 additions and 64 deletions
+18
View File
@@ -9,8 +9,22 @@ server {
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Prevent caching of index.html and sw.js so redeploys fetch new assets immediately
location ~* (index\.html|sw\.js|manifest\.json)$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
# Cache immutable static assets with hash (js, css, images) for performance
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2)$ {
expires 1y;
add_header Cache-Control "public, max-age=31536000, immutable";
}
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
location /api/ {
@@ -31,5 +45,9 @@ server {
location /static/ {
proxy_pass http://backend:8000/static/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}