Hotfix/Cache bust all js files #21

Merged
jusemon merged 2 commits from hotfix/cache-bust-all-js-files into main 2025-11-26 19:40:41 -05:00
Showing only changes of commit ab82a6f874 - Show all commits

View file

@ -9,11 +9,19 @@ server {
try_files $uri $uri/ =404; try_files $uri $uri/ =404;
} }
# Prevent caching of JavaScript files and version.json # Cache JavaScript files with version query params for 1 year (immutable)
location ~* \.(js|mjs)$ { # Files without version params are not cached
add_header Cache-Control "no-cache, no-store, must-revalidate"; location ~* \.(js|mjs)(\?v=[^&]+)?$ {
add_header Pragma "no-cache"; if ($args ~ "v=") {
add_header Expires "0"; # Has version param - cache for 1 year (immutable)
add_header Cache-Control "public, max-age=31536000, immutable";
}
if ($args !~ "v=") {
# No version param - don't cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
add_header Vary "Accept-Encoding"; add_header Vary "Accept-Encoding";
} }