I've installed nginx/1.10.3 (Ubuntu) and changed the original config file so that it is only slightly different at the top of the http context:
http {
add_header 'Cache-Control' 'no-cache';
and this is working. I will see 'no-cache' in the response headers when I access the index.html (tested with / and /index.html). And I can add more attributes like 'no-store', that will also work, it's really working here.
But I'd like to restrict the no-cache to only the index.html, and I can't get this to work.
http {
server {
location = /index.html {
add_header 'Cache-Control' 'no-cache';
}
}
does not work, no 'no-cache' appears in the response headers (tested with / and /index.html). Also not working are location / { ...
, and location ~
and location ~*
with a regexp.
I'm lost here. I'll reinstall nginx and check if there is a typo. Am I doing this correctly at all?
Edit: I purged and reinstalled nginx, did the same things again, got the same result.