Cache-Control headers repeated; valid or not? (Nginx)

后端 未结 2 886
遇见更好的自我
遇见更好的自我 2020-12-10 23:45

I\'ve got a resource in my Nginx that is configured like this:

location ~ foo\\.js$ {
    add_header Cache-Control public;
    expires 1d;
}
<
2条回答
  •  孤街浪徒
    2020-12-11 00:31

    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.

提交回复
热议问题