简体   繁体   中英

Varnish 3 caching logged in pages as well

I'm scratching my head for 2 days with no luck. I've configured Varnish 3 with Pressflow 6 (Drupal) and everything is good ie Varnish is caching the pages. Now the pain is Varnish is caching even after login. So when i do logout i still see your are logged in messages etc.

I tried to set a unique cookie upon Login in modules/user/user.module file and modified the /etc/varnish/default.vcl file adding the following block.

if (req.http.Cookie ~ "(MY_UNIQUE_COOKIE)") {
  return (pass);
}

Everything works as expected now but in logout script, i am not able to completely delete the cookie via PHP ie setting the time in minus. I believe the actual cookie goes away after the browser is closed/restarted.

So now onwards, if i don't close the browser, the cookie is there and Varnish always send every page to Apache Backend.

Any help would be highly appreciated.

Regards,

Raheel

I know this is an old question, but I thought I could provide some input about this.

I don't know Varnish's syntax yet, but on logout you could set the value of the cookie to be empty. Then you can strip all of the empty cookies out of the headers in VCL. This will make varnish behave the way you intend.

The first 3 Google results for "drupal pressflow varnish" are gold. 2 posted because I apparently don't have enough rep but the osuosl blog post is really good to if maybe a little dated

  1. http://www.lullabot.com/articles/varnish-multiple-web-servers-drupal
  2. https://wiki.fourkitchens.com/display/PF/Configure+Varnish+for+Pressflow

Also, you should never modify Drupal's core code. It will make your life upgrading miserable and anything you would want to do you can almost certainly manage with the integration points and maybe a litte ingenuity

Finally, as you will notice in the linked articles, there is no reason to set your own cookie because Pressflow and Drupal 7+ have optimized session creation so the session cookie already provides the functionality you're looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM