Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 清漆3 VCL正则表达式_Regex_Caching_Varnish - Fatal编程技术网

Regex 清漆3 VCL正则表达式

Regex 清漆3 VCL正则表达式,regex,caching,varnish,Regex,Caching,Varnish,我一直在努力匹配varnish 3 vcl中的这个url模式 www.example.com/alpha/76/Permanent/ if ((req.url ~ "/*/*/Permanent/$")) { set beresp.http.Cache-Control = "public, max-age=1400, s-maxage=1400"; set beresp.ttl = 30m; return(deliver); } 但这似乎不符合条件。知道我错在哪里吗?/*表示

我一直在努力匹配varnish 3 vcl中的这个url模式

www.example.com/alpha/76/Permanent/

if ((req.url ~ "/*/*/Permanent/$")) {
   set beresp.http.Cache-Control = "public, max-age=1400, s-maxage=1400";
   set beresp.ttl = 30m;
   return(deliver);
}

但这似乎不符合条件。知道我错在哪里吗?

/*
表示零个或多个斜杠(这不是)。你应使用:

^/\w+/\w+/Permanent/$
\w+
将匹配一个或多个字母数字字符


来源:

它也匹配这个:example.com/Apha/Beta/222/194442/Permanent/,可以做什么,它只匹配这个模式example.com/alpha/76/Permanent/@GoodtheBesT例如,你可以使用
/\w+/\w+/Permanent/$
-这将只匹配字母数字字符。但它可能仍然匹配URL的结尾…但它仍然与example.com/Apha/Beta/222/194442/Permanent/和example.com/alpha/76/Permanent/模式匹配。虽然我希望它只与以下模式匹配:example.com/alpha/76/Permanent/@GoodtheBesT-在开始时尝试
^
^/\w+/\w+/Permanent/$
:^worked,但如果排除www.example.com而不是缓存,而是缓存其他文件夹和页面,该怎么办?我们可以排除带有任何条件的登录页吗?