我有一个varnish 3.xx服务器,目前可以正常工作。Varnish正在缓存我网站的登录页面。
www.mysite.com/staff
但它可能具有不同的urls,这取决于员工链接,例如
www.mysite.com/staff/index.php?/Tickets/Ticket/View/222200
我的varnish配置文件如下所示,以排除缓存人员页面,但它不工作,因为它正在缓存登录页面,它将不会登录,直到我重新启动varnish以清除它的缓存。
sub vcl_recv {
# Allow purge only from internal users
if (req.request == "PURGE") {
if (!client.ip ~ internal_net) {
error 405 "Not allowed.";
}
return (lookup);
# Exclude the following
if (req.url ~ "^/login\.php" ||
req.url ~ "^/search\.php" ||
req.url ~ "^/admin(.*)" ||
req.url ~ "^/admin(.*)" ||
req.url ~ "^/search(.*)" ||
req.url ~ "^/visitor(.*)" ||
req.url ~ "^/staff(.*)" ||
req.url ~ "^/staff\.php"
) {
return(pass);
}
if (req.http.cookie ~ "vb(.*)" ||
req.http.cookie ~ "bb(.*)" ||
req.http.cookie ~ "SWIFT_(.*)" ||
req.url ~ "\?(.*\&)?s=[a-fA-F0-9]{32}(\&|$)" ||
req.http.cookie ~ "bb_password") {
return(pass);
} else {
unset req.http.cookie;
}
}您是否有其他方法可以从缓存中排除和整个目录?IE:来自/staff的所有内容,无论后缀是什么,都不能缓存
发布于 2012-11-15 18:59:07
排除应该以您已经实现的方式完美地工作。但是,如果粘贴的代码是实际的VCL,那么在PURGE部分有一个open if()语句。
sub vcl_recv {
# Allow purge only from internal users
if (req.request == "PURGE") {
if (!client.ip ~ internal_net) {
error 405 "Not allowed.";
}
return (lookup);
# Exclude the following应该阅读
sub vcl_recv {
# Allow purge only from internal users
if (req.request == "PURGE") {
if (!client.ip ~ internal_net) {
error 405 "Not allowed.";
}
return (lookup);
}
# Exclude the followingVarnish不应该接受无效的VCL,因此如果错误不存在于您的实际VCL中,请使用您的整个VCL更新问题。
https://stackoverflow.com/questions/13191828
复制相似问题