I\'ve got a resource in my Nginx that is configured like this:
location ~ foo\\.js$ {
add_header Cache-Control public;
expires 1d;
}
<
I was having the same problem on different configuration. What worked for me is to change the order of two lines that set headers and place header setting just after "server" opening bracket. This will set headers to all objects perhaps but maybe will work in you "if" statement too:
server {
expires 31d;
add_header Cache-Control public;
server_name example.com
...
}
It seems that add_header sends header before expires directive to have time to change it.