February 12, 2011 03:56PM
On Sat, Feb 12, 2011 at 03:47:22PM -0500, Dayo wrote:
> 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.

Note, that order is important for locations with regex. And this is
causes configuraiton dependences. This is why I try to avoid regexes
or try to isolate them as nested locations inside usual locations.

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


--
Igor Sysoev
http://sysoev.ru/en/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
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: 252
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