fix: never cache index.html so new bundle hashes are picked up
Vite content-hashes the JS/CSS bundle filenames, but the only thing that tells the browser to fetch a new hash is a fresh index.html. Without explicit no-cache headers nginx falls back to heuristic caching, so users keep loading the old index.html → old bundle hash until they hard-reload. Just hit this rolling out the timeline pagination fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -35,7 +35,18 @@ server {
|
|||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Cache static assets
|
# Never cache index.html (or any HTML). The asset filenames are
|
||||||
|
# content-hashed by Vite, so a fresh index.html is the only thing
|
||||||
|
# that tells the browser to fetch the new bundle. Without this the
|
||||||
|
# browser happily serves a stale index.html → stale bundle hash →
|
||||||
|
# users see the old build until they hard-reload.
|
||||||
|
location = /index.html {
|
||||||
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||||
|
add_header Pragma "no-cache";
|
||||||
|
expires 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Cache static assets (filenames are content-hashed, so 1y is safe)
|
||||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
expires 1y;
|
expires 1y;
|
||||||
add_header Cache-Control "public, immutable";
|
add_header Cache-Control "public, immutable";
|
||||||
|
|||||||
Reference in New Issue
Block a user