Discussions

Commerce and varnish

Har anyone tried using Varnish on a Drupal Commerce website?

Would it work with shopping carts and other cookie-related stuff?

Posted: Nov 16, 2011

Comments

rfay Randy Fay on November 16, 2011

Varnish caches pages. But your webstore visitor wants the page to change every time they take an action (like adding something to the cart). Varnish also by default wants to strip cookies and session information. I doubt you're going to get value out of it for your store.

commercestudy on November 18, 2011

So varnish ESI would still have its place for non logged in visitors to high traffic Drupal sites if it could be implemented. Then no varnish for people who are logged in?

rfay Randy Fay on November 19, 2011

Basically, that's the key use of varnish right now with Drupal: You serve pages cached from varnish to unauthenticated users (it never even hits Drupal except the first time) but authenticated users get served by Drupal and the webserver itself.

Prince Manfred on November 20, 2011

You can setup pretty complex caching in Drupal without using something like Varnish. If you have the ability to setup Varnish you can probably also setup memcache. http://drupal.org/project/memcache This module swaps out the database caching system that Drupal uses by default for a high-performance, memory-based cache. Google around for different caching options you can pull off with Drupal. I'm using a custom Views plugin to manage a cache for the product catalog on a site I'm building. That way the database doesn't have to be hit except for the first user that views it after it's been updated. It works for anonymous and logged in users. There are all kinds of things you can do if you get creative. : )

commercestudy on November 21, 2011

What you have done with views regarding caching sounds really, really interesting!

AdamGerthel on January 11, 2012

I just tried Boost (http://drupal.org/project/boost), and it gave and amazing performance increase with very little setup hassle. Ofcourse, it doesn't work very well with Commerce like Randy mentioned. Can boost handle caching only parts of a page?

KlavsKlavsen on February 29, 2012

when using an ajax cart - a cookie should not be needed on every request - only the requests coming from the ajax cart, needs to go past varnish uncached.

I haven't tested the current ajax cart for drupal commerce yet - but that is how it "should" work - so you could fully cache a drupal commerce site with varnish.

Just remember to tell varnish to not cache checkout url's.

I'd recommend playing with ajax cart and see how far that gets you.

Drupal will probably put a std. "anonymous" cookie - so you need to get drupal to have a seperate "is_logged_in" or similar - cookie, when the user is actually logged in, so you can seperate an anonymous cookie, vs. a logged-in users cookie.

veganline on October 24, 2012

Drupal Commerce 2 Demo is on an aquia stack server on my hard disc.
It isn't very fast. I thought demo versions on hard discs were meant to be lightening-fast, with the dissapointment later!

What's the best cache configuration?

Varnish!

I'll ask this as a new thread linked to this if nobody replies. It may be relevant that DrupalCommerce2 has its own screen for chache configuration which makes it harder to interpret more general advice

wadmiraal on April 3, 2013

Hi all.

We ran into this problem as well and decided to give Authcache a try. We turned the resulting code into a very simple module (for now) called Commerce Authcache.

But we're in need of additional testers and suggestions ! There must be other parts of Drupal Commerce that need to be excluded from the cache as well. If some of you have ideas or suggestions, please open a new Feature Request in the module issue queue, so we can implement them. Patches are more than welcome !

Kind regards,

W