plone.recipe.varnish does not cache any requests with cookies
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
collective.buildout |
New
|
Undecided
|
Unassigned |
Bug Description
I'm using varnish 2.0-beta2 with plone.recipe.
Header add Set-Cookie "__balancer_
The result is that no pages get cached at all, as there is always a Cookie header in the request. Presumably this observation would also hold true for all logged in users too with the __ac cookie even without the stickysession cookies, or users with the google analytics __utm. cookies.
To fix this I had to customise the vcl. Ideally I would have liked to ignore only double underscore cookies, but I couldn't quite work out how.
I think this would be safe for the default CacheSetup configuration, though it may cause problems if you want to cache html pages. Maybe for that case there should be some more logic in a sub vcl_hit to force a pass if the content type is text/html and the user is authenticated.
Index: varnish.vcl
=======
--- varnish.vcl (revision 690)
+++ varnish.vcl (working copy)
@@ -30,6 +30,14 @@
if (req.http.
pass;
}
+
+ # ignore cookies starting with underscore
+ if (req.request == "GET" && !(req.http.
+ if (req.http.cookie ~ "(^| )[^_](.+?)($|;)") {
+ pass;
+ }
+ lookup;
+ }
}
sub vcl_pipe {
Following up from discussions elsewhere:
I'm agnostic as to the open-ending of the generated vcl-config. It's ike a nice idea and seems to be the recommended approach from reading the varnish docs, but it does seem to hide some complexity.
Regardless, I think we need to solve this issue of caching requests with cookies, the current behaviour is largely useless for a Plone site.