"root" directive weirdness

Marcus Clyne ngx.eugaia at gmail.com
Fri Jan 22 09:42:05 MSK 2010


Cliff Wells wrote:
> On Fri, 2010-01-22 at 05:15 +0200, Marcus Clyne wrote:
>   
>> Cliff Wells wrote:
>>     
>>> On Fri, 2010-01-22 at 02:45 +0200, Marcus Clyne wrote:
>>>   
>>>       
>>>>>   
>>>>>       
>>>>>           
>>>> but using
>>>>
>>>> location ^~ /users/ {
>>>>     root   /web;
>>>> }
>>>>
>>>> is more efficient than using
>>>>
>>>> location /users {
>>>>     root /web;
>>>> }
>>>>     
>>>>         
>>> That's not true.   The regex is less efficient.
>>>   
>>>       
>> It's not a regex (regexes are indicated by ~*).  It's a test for the URL 
>> beginning with the represented string.  If found, it does not test any 
>> regexes.  Using just
>>
>> location  /users
>>
>> will test regexes before returning the /users location if no regexes match.
>>     
>
> I stand corrected.   I should have read the documentation you so
> thoughtfully linked to =)
>   
:-)

I'm actually not a huge fan of the ^~ syntax.  I think it's confusing, 
because it does more closely resemble the regex syntax than a static 
one.  I suspect that a lot of people don't use it because of this, 
thinking that it will be less efficient when in fact it is more so.

I think ^= would be less confusing, or even just plain ^, but I doubt 
that it'll get changed.

Cheers,

Marcus.



More information about the nginx mailing list