Hotfix/Cache bust all js files #21
1 changed files with 13 additions and 5 deletions
12
nginx.conf
12
nginx.conf
|
|
@ -9,11 +9,19 @@ server {
|
|||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
# Prevent caching of JavaScript files and version.json
|
||||
location ~* \.(js|mjs)$ {
|
||||
# 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";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue