我正在寻找一种方法来清除Varnish中所有域和所有URL的缓存。
当前,我需要为每个URL发出单独的命令,例如:
curl -X PURGE http://example.com/url1
curl -X PURGE http://example.com/url1
curl -X PURGE http://subdomain.example.com/
curl -X PURGE http://subdomain.example.com/url1
// etc.
当我在寻找一种方法来做类似的事情
curl -X PURGE http://example.com/*
这将清除example.com下的所有URL,也清除example.com子域中的所有URL,基本上是Varnish管理的所有URL。
任何想法如何实现这一目标?
这是我当前的VCL文件:
vcl 4.0;
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
# Command to clear the cache
# curl -X PURGE http://example.com
if (req.method == "PURGE") {
return (purge);
}
}
在Varnish 4.0中,我最终使用以下ban
命令实现了它:
sub vcl_recv {
# ...
# Command to clear complete cache for all URLs and all sub-domains
# curl -X XCGFULLBAN http://example.com
if (req.method == "XCGFULLBAN") {
ban("req.http.host ~ .*");
return (synth(200, "Full cache cleared"));
}
# ...
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句