2012-11-02 58 views
4

我有一个清漆3.xx服务器,目前的作品。 Varnish正在缓存我网站的登录页面。清漆排除网址

www.mysite.com/staff

,但它可能取决于工作人员连接不同的URL,例如

www.mysite.com/staff/index.php?/Tickets/Ticket /查看/ 222200

我的清漆配置文件设置如下,以排除缓存员工页面,但它不工作,因为它缓存登录页面,它不会登录,直到我重新启动清漆清除它的缓存。

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:从/员工的一切,不管后缀是什么,不得缓存

回答

3

排除应该完全按照你实施它的方式工作。但是,如果您粘贴的代码是您的实际VCL,则您在PURGE部分中有一个开放的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 following 

光油不应接受无效的VCL虽然,所以如果错误不实际的VCL存在,请更新您的整个VCL的问题。

+0

谢谢你,你在钱上,这对我们有效。 – rezizter