我正在维护的 Wordpress 博客之一没有使用插件Varnish HTTP Purge 清除缓存。无论是使用清漆缓存清除按钮还是在我们编辑帖子时。
为了知道问题的原因,我想知道一种方法来检查清除请求是否到达 Varnish 服务器,可能使用 varnishlog 命令。
我正在维护的 Wordpress 博客之一没有使用插件Varnish HTTP Purge 清除缓存。无论是使用清漆缓存清除按钮还是在我们编辑帖子时。
为了知道问题的原因,我想知道一种方法来检查清除请求是否到达 Varnish 服务器,可能使用 varnishlog 命令。
清漆 4.0
varnishlog -g request -q 'ReqMethod eq "PURGE"'
Varnish 3.x
varnishlog -d -c -m RxRequest:PURGE
That will output any of the purges in memory. And without -d
it will output only current requests:
varnishlog -c -m RxRequest:PURGE
From man varnishlog
:
-d
Process old log entries on startup. Normally, varnishlog will only process entries which are written to the log after it starts.
它可以像清漆配置一样简单,将清除请求限制到某个 IP 或一组 IP。我知道我的典型清漆配置包括:
acl purge {
"127.0.0.1";
"123.45.67.0"/24;
}
sub vcl_recv {
....
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
return (lookup);
}
....
}
我会先检查一下,尤其是从 varnish 网站上的一些示例中复制了配置。几乎所有这些都包含用于清除的 ACL。