nginx - 特定数量的请求后,在Varnish-Cache中缓存资源

标签 nginx caching varnish varnish-vcl

proxy_cache_min_uses中是否有类似Nginx的Varnish-Cache的功能在对资源进行特定数量的请求后缓存该资源?
这是Varnish-Cache plus中的一些类似解决方案(基于slimhazardthis issue的评论):

import vsthrottle;

sub vcl_recv {
    if (req.url ~ "^/min/use/me" && vsthrottle.is_denied(req.url, 50, 2h, 1h) {
        # If the URL was requested more than 50 times during the last two hours,
        # then go to cache lookup for the next hour.
        return (hash);
    }
    else {
        # Otherwise bypass the cache
        return (pass);
    }
}

是否可以在Varnish-Cache本身中使用任何类似的解决方案?

最佳答案

它本身不在Varnish Cache内核中,但是您可以使用VMOD来实现此目的,例如this counter VMOD

它将允许您在请求资源的次数中增加某些计数器的数量,然后检查其值并应用所需的缓存逻辑。

关于nginx - 特定数量的请求后,在Varnish-Cache中缓存资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59163972/

相关文章:

django - 不要在上传模块的帮助下跨 nginx 上传文件

webserver - 使用 nginx 返回自定义 403 错误页面

javascript - 预加载大型 JSON 文件

java - 如何在 Spring 4.2 或更高版本中设置 Cache-control : private with applicationContext. xml

kubernetes - 在kubernetes部署中配置Varnish后端

nginx - Varnish + nginx和压缩的SVG

regex - 如何在 nginx 中转换(重写)部分 URL

php - Laravel 403 无效签名仅在 Nginx Web 服务器上

caching - 如果第一个响应是 AppCache (Symfony2) 私有(private)的,可以吗?

docker-compose - docker varnish cmd 错误 - 没有这样的文件或目录