regex - 提取 Varnish 中查询参数的值

标签 regex caching varnish query-string

我有这个网址:

http://my.api.com/v1/{api_key}/{user_token}/?someparam=hello&force=true&someotherparam=world

其中 api_keyuser_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/

相关文章:

caching - 如何通过分页检测搜索结果中的陈旧数据?

使用mod-xsendfile的PHP文件下载不会下载整个文件

regex - 解释这个正则表达式 : (? :|{}I )

javascript - 如何在 JavaScript 正则表达式中获取子模式的索引?

正则表达式 - 只有一个特殊字符

javascript - 如何在没有缓存/cookie 的情况下运行/调试 Web 应用程序元素?

javascript - 正则表达式匹配年份,但不匹配javascript中的其他数字

php - 共享主机上的 Symfony 2 - 允许的内存大小已耗尽

magento - 当magento发回前端cookie时如何提供缓存页面

caching - Varnish 缓存丢失-由VCL决定的TTL为0