Stop caching index.html and speed up socket reconnect
CI/CD / backend (pull_request) Successful in 5m41s
CI/CD / frontend (pull_request) Successful in 5m18s
CI/CD / build (pull_request) Skipped
CI/CD / deploy (pull_request) Skipped
CI/CD / cleanup (pull_request) Skipped

Phones offer no easy hard-refresh, so a cached index.html kept serving an old
bundle after a deploy (the live feed showed "reconnecting"). index.html and the
SPA catch-all now send Cache-Control: no-store, while hashed /assets stay
immutable. Also retry the first socket reconnect after 1s (was 2s) and surface
the close code in the header so a failure is actionable on a phone.
This commit is contained in:
matitos committed 2026-09-19 23:52:54 +00:00
1 parent 6df44520fa
commit c63753e592
3 files changed
+33 -6

No files matched your search

+15
View File
@@ -4,7 +4,22 @@ server {
root /usr/share/nginx/html;
index index.html;
# Hashed Vite assets are immutable; cache them hard.
location /assets/ {
add_header Cache-Control "public, max-age=31536000, immutable";
try_files $uri =404;
}
# The HTML entry point must never be cached, or a phone (which offers no
# easy hard-refresh) keeps loading an old bundle after a deploy. The
# catch-all serves index.html for client-side routes, so it gets the same
# no-store header.
location = /index.html {
add_header Cache-Control "no-store";
}
location / {
add_header Cache-Control "no-store";
try_files $uri $uri/ /index.html;
}