I want to easily clear the browser's cache when js/css files are updated.
Real file location:
- /js/some-files.js
- /css/some-files.css
File location set in the app to be called by browser:
- /js/v1/some-files.js
- /css/v1/some-files.css
I tried the following but going to /js/v1/some-files.js gives me 404s.
location ~ ^/(js|css)/v[0-9]+/(.*)$ {
access_log off;
expires 7d;
add_header Cache-Control public;
try_files $uri $uri/ $1/$2;
}
Can you spot what I'm doing wrong?
It was due to missing slash, as mentioned in the comments! Additionally, your location block can be simplified like the following...