Take this Nginx location config as example:
location ~* \.(gif|jpg|jpeg|swf|css)$ {
add_header Cache-Control "max-age=259200, public";
}
location ^~ /abc/ {
try_files $uri /abc/generic.png;
}
For request /abc/x.jpg, it will match the 2nd location, and the response will NOT have Cache-Control header. How do I do to have the Cache-Control header applied to /abc/x.jpg as well?
Something like this would work, but it is kinda duplicating.
location ~* \.(gif|jpg|jpeg|swf|css)$ {
add_header Cache-Control "max-age=259200, public";
}
location ^~ /abc/ {
try_files $uri /abc/generic.png;
location ~* \.(gif|jpg|jpeg|swf|css)$ {
add_header Cache-Control "max-age=259200, public";
}
}