清漆:如何添加dynamic网页瓦特/cookies例外

我想知道什么是正确的方法来避免使用Varnishcaching“一些网页”的网站和caching所有其他人。

这是我试图做的与vcl conf:

sub vcl_fetch { #set beresp.ttl = 1d; if (!(req.url ~ "/page1withauth") || !(req.url ~ "/page2withauth")) { unset beresp.http.set-cookie; } if (!beresp.cacheable) { return (pass); } if (beresp.http.Set-Cookie) { return (pass); } return (deliver); } 

谢谢

通常,这将在vcl_recv中完成:

 sub vcl_recv { if ( req.url !~ "^/page1withauth" && req.url !~ "^/page2withauth" ) { unset req.http.Cookie; remove req.http.Cookie; } } 

然后,唯一一次你应该有一个从服务器返回的set-cookie参数是当你试图唯一标识连接。 如果这是因为他们只是发布或类似的,这已经逃避了caching。 如果是因为你只是想要唯一标识它们,那么问题是你的应用程序的代码有意打破光油; 修复你的应用程序,如果可以的话,否则你可以覆盖vcl_fetch类似于你在这里做什么。