Welcome! Log In Create A New Profile

Advanced

Re: Setting expires header to multiple locations

Antonio P.P. Almeida
December 14, 2012 07:00AM
> Currently I need to use tricks since I have multiple locations in my site
> config.
>
> e.g.
>
> =====================================
>
>
> location ~* /a {
> location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ {
> expires 1y;
> }
> }
>
> location ~* /b {
> location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ {
> expires 1y;
> }
> }
>
> location ~* /c {
> location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ {
> expires 1y;
> }
> }

Going against Igor, Maxim, Valentin and Ruslan in order to be more DRY you
could use a regex based location (which has its own quirks):

location ~* ^/(?:a|b|c)/.*\.(?:css|gif|js|jpe?g|png)$ {
expires 1y;
}

--appa

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Setting expires header to multiple locations

howard chen December 14, 2012 06:32AM

Re: Setting expires header to multiple locations

Edho Arief December 14, 2012 06:40AM

Re: Setting expires header to multiple locations

Antonio P.P. Almeida December 14, 2012 07:00AM

Re: Setting expires header to multiple locations

Igor Sysoev December 14, 2012 07:38AM

Re: Setting expires header to multiple locations

howard chen December 14, 2012 09:44AM

Re: Setting expires header to multiple locations

howard chen December 14, 2012 09:40AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 292
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready