Welcome! Log In Create A New Profile

Advanced

Re: Setting expires header to multiple locations

December 14, 2012 07:38AM
On Dec 14, 2012, at 15:59 , Antonio P.P. Almeida wrote:

>> 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;
> }

This valid only if "~* /b" was intended for "~* ^/b".

As to me, I prefer to isolate regex locations (if I have to use them at all)
inside usual locations:

location /c {
location ~* \.(?:css|js|jpg|jpeg|gif|png)$ {
expires 1y;
}
}

Of course this requires more time to type, but allows me to spend much
less time when I need to modify configuration in future.


--
Igor Sysoev
http://nginx.com/support.html

_______________________________________________
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: 119
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready