我遇到了Varnish中清除配置的问题。我有一个配置如下的清除URL,但在尝试启动服务时,我收到错误,也在下面。如果我注释掉这条配置,服务就会毫无问题地启动。有没有人有任何想法我会出错?
干杯。
sub vcl_recv {
#purge all
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
if (req.url ~ "varnish/index/purgeall/key/#Fj1nzljh") {
purge_hash( ".*" );
}
}
开始时的错误消息为:
user@ubuntu:/var/www$ sudo service varnish start
* Starting HTTP accelerator varnishd [fail]
storage_file: filename: /var/lib/varnish/ubuntu/varnish_storage.bin size 1024 MB.
Message from VCC-compiler:
Expected an action, 'if', '{' or '}'
(input Line 18 Pos 7)
purge_hash( ".*" );
------##########---------
Running VCC-compiler failed, exit 1
VCL compilation failed
mark@ubuntu:/var/www$ sudo service varnish start
* Starting HTTP accelerator varnishd [fail]
storage_file: filename: /var/lib/varnish/ubuntu/varnish_storage.bin size 1024 MB.
Message from VCC-compiler:
Expected an action, 'if', '{' or '}'
(input Line 18 Pos 7)
purge_hash( ".*" );
答案 0 :(得分:1)
在3.0.x中执行此操作的正确方法是这样的:
acl our_lan {
"localhost";
"10.0.0.0"/8;
"192.168.0.0"/16;
}
sub vcl_recv {
# ...
if (req.request == "PURGE") {
if (! (client.ip ~ our_lan)) {
error 405 "Not allowed.";
}
return (lookup);
}
# ...
}
sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
error 200 "OK: but URL not in cache.";
}
}
因人而异。
答案 1 :(得分:0)
purge_hash似乎已在最新版本的varnish http://www.varnish-cache.org/trac/changeset/e20226fa977bb3e05d49b4e497a0b9f64ca5f272
中删除似乎你想要清除整个缓存,你可以用其他清除函数来实现它