在proxy_cache_min_uses中是否有类似Nginx的Varnish-Cache的功能在对资源进行特定数量的请求后缓存该资源?
这是Varnish-Cache plus中的一些类似解决方案(基于slimhazard对this 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/