In my nginx
config, I have serveral location blocks, e.g.
location ~* /a { ..}
location ~* /b { ..}
location ~* /c { ..}
And I want to apply the expires
header to all of above blocks, e.g.
location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ {
expires 1y;
}
Since in nginx
, location blocks are exclusive to each other, so
instead of repeating [1] the expires
block in each of my locations above, are there better way to write the config?
[1]
location ~* /a {
location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ ...
}
location ~* /b {
location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ ...
}
location ~* /c {
location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ ...
}