【发布时间】:2013-11-13 07:50:12
【问题描述】:
NGINX
有一个类似的位置:
location ~ "^\/(place1|place2|...|place50)\/(service1|service2|...|service80)\-(else1|else2|...|else90)\/"
{...}
location ~ "^\/(word1|word2|...|word70)\/(place1|place2|...|place50)\-(else1|else2|...|else90)\/"
{...}
location ~ "^\/..."
问题是有很多地方、服务、文字等等。所以位置是非常长的字符串。是否有可能使它们更短?也许有大量的地方和大量的服务等等?或者其他的东西?谁有经验?
我要匹配的 URI 示例
/place23/service17-else87/
或
/world33/place42-else15/
以及任何组合
对于每个位置,我们将使用一组规则。为了使用缓存和卸载我们的 Apache
#proxy_cache start
set $do_not_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $do_not_cache 1;
}
if ($query_string != "") {
set $do_not_cache 1;
}
# Don't use the cache for logged in users or REBent commenters
if ($http_cookie ~* "wordpress_logged_in|bn_my_logged") {
set $do_not_cache 1;
}
if ($args ~* (show) ) {
set $do_not_cache 1;
}
ssi_types "*";
ssi on;
if ($do_not_cache = 0) {
set $memcached_key "SMREG|$request_uri";
memcached_pass memc_server;
ssi on;
}
【问题讨论】:
-
你能举出你想匹配的URI的例子吗
-
刚刚添加了示例
-
为什么要在 Web 服务器级别而不是应用程序级别处理这些?