I have the following config (for an Angular app):
location / {
try_files $uri /index.html;
add_header "Cache-Control" "no-cache" ;
}
Now I would like to add that header only for index.html
, but not for any other files. How to do that?
using the “=” modifier it is possible to define an exact match of URI and location. If an exact match is found, the search terminates.
so you can use this configure :
location =/index.html {
add_header "Cache-Control" "no-cache" ;
}
location / {
rewrite ^(.*) /index.html break;
}
you can find more information in