Welcome! Log In Create A New Profile

Advanced

Re: Nested Locations Better???

February 12, 2011 03:47PM
Igor Sysoev Wrote:
-------------------------------------------------------
> If you use only locations without regexes, then
> you may not use nested
> locations. nginx uses some kind of binary tree to
> match locations, so
>
> location /set/subset/ { }
> location /set/ { }
>
> are slightly faster than nested locations. BTW you
> may write
>
> location /set/ { }
> location /set/subset/ { }
>
> or
>
> location /set/subset/ { }
> location /set/ { }
>
> - there is no difference for nginx: it finds the
> longest match using
> the tree.

Understood. Thanks. I'll continue to order them as ...

location /set/subset/ { }
location /set/ { }

... just to maintain consistency with what I have done before.

> The nested locations are better if you
> had to use regex
> locations. Then I usually isolate regex location
> inside usual location:
>
> location /dir/ {
> location ~ ^/dir/(.+)$ {
> ...
> }
> }

Got it. The example I was referring to had ...

location ~ subset { }
location ~ set { }

... so I will nest them as per your indication in the original response

> > Also, how many layers deep can this go if so?
>
> No limit, except memory, etc.

Good to know. I don't expect to go deep than one layer anyway.

Thanks for the clarification.
Subject Author Posted

Nested Locations Better???

Dayo February 12, 2011 02:33PM

Re: Nested Locations Better???

Igor Sysoev February 12, 2011 03:22PM

Re: Nested Locations Better???

Dayo February 12, 2011 03:47PM

Re: Nested Locations Better???

Igor Sysoev February 12, 2011 03:56PM

Re: Nested Locations Better???

Dayo February 12, 2011 04:00PM

Re: Nested Locations Better???

Igor Sysoev February 12, 2011 04:12PM

Re: Nested Locations Better???

Dayo February 12, 2011 04:22PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready