首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

在nginx中为啥要尽量避免使用regex location

2012-07-03 
在nginx中为什么要尽量避免使用regex location这是nginx的作者Igor在邮件列表中的回答:A:Im wondering ab

在nginx中为什么要尽量避免使用regex location
这是nginx的作者Igor在邮件列表中的回答:

A:I'm wondering about the regex usage in location though - this is one of
the things I like very much about nginx. Can you please elaborate the reasons for avoiding them?


Q:The difference is how nginx processes location.

If you use only prefix or exact locations, then nginx looks up
the longest match nevertheless of order of locations in configuration file.
This allows you to have hundreds or thousands locations without worrying
how a new location will affect the existant configuration.

Regex locations depend on order, so during adding a new location
you have to look though whole configuration to see if the new location
will affect it.

A man thinks usually that he creates a small configuration with regexes
and it will work always fine. But configuration usually grows eventually
and at some point it become a difficult task to add new locations.

Rewrite rules aggravate this more.

热点排行