Nested Locations Better???
Dayo
nginx-forum at nginx.us
Sat Feb 12 23:47:22 MSK 2011
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.
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,174517,174538#msg-174538
More information about the nginx
mailing list