我有这个网址:
http://my.api.com/v1/{api_key}/{user_token}/?someparam=hello&force=true&someotherparam=world
其中 api_key
和 user_token
是 uuid
如何提取 force
查询参数的值,如果强制参数丢失或设置为 false,则从 varnish 缓存中进行查找。如果它设置为 true,我需要访问我的后端服务器。查询参数可以按任何顺序。
最佳答案
我建议你反转逻辑:
sub vcl_recv {
if (req.url ~ "(?i)force=(true|yes)") {
return(pass);
}
// other values will fall through to the safe default VCL that will do return(lookup).
}
关于regex - 提取 Varnish 中查询参数的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13701352/