Hotfix/Cache bust all js files (#21)
All checks were successful
Build and Publish Docker Image / Publish to Registry (push) Successful in 8s
Build and Publish Docker Image / Deploy to Portainer (push) Successful in 2s

Reviewed-on: #21
Co-authored-by: Juan Sebastian Montoya <juansmm@outlook.com>
Co-committed-by: Juan Sebastian Montoya <juansmm@outlook.com>
This commit is contained in:
Juan Sebastián Montoya 2025-11-26 19:40:41 -05:00 committed by Juan Sebastián Montoya
parent 9739d5e8e9
commit 98ec60641d
3 changed files with 64 additions and 5 deletions

View file

@ -9,11 +9,19 @@ server {
try_files $uri $uri/ =404;
}
# Prevent caching of JavaScript files and version.json
location ~* \.(js|mjs)$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
# Cache JavaScript files with version query params for 1 year (immutable)
# Files without version params are not cached
location ~* \.(js|mjs)(\?v=[^&]+)?$ {
if ($args ~ "v=") {
# 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";
}