WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
WooThemes documented Varnish (cache) VCL config does not compile (5 posts)

  1. berler
    DreamHost Developer
    Posted 11 months ago #

    Currently at http://docs.woothemes.com/document/configuring-caching-plugins/ it says to use the following Varnish config:

    if (req.url ~ "^/(cart|my-account|checkout|addons)") {
     return (pass);
     }
    if ( req.url ~ "?add-to-cart=" ) {
     return (pass);
     }

    However this will fail to compile in the current version of Varnish. The "?" must be escaped because "?" is a regex metacharacter. It probably also should be noted that this code should be inside the vcl_recv function. This would fix those problems:

    sub vcl_recv {
      if (req.url ~ "^/(cart|my-account|checkout|addons)") {
       return (pass);
      }
      if (req.url ~ "\?add-to-cart=") {
       return (pass);
      }
    }

    This will at least compile, although I'm not sure if there are any other things that need to be changed in the config.

    http://wordpress.org/extend/plugins/woocommerce/

  2. Pothi
    Member
    Posted 11 months ago #

    Thanks for sharing the fix.

  3. Ipstenu-DH
    DreamHost Rep
    Posted 11 months ago #

    FYI, I emailed them directly about this too :)

  4. rafaelmagic
    Member
    Posted 11 months ago #

    Do any of you guys have a working Varnish VLC config file. Since Woo Commerce uses session cookies it disables Varnish.

    Thanks

  5. yolabingo
    Member
    Posted 2 months ago #

    I have had decent success with Woo Commerce + Varnish after a week of tweaking. I ended up using the nuclear option "pipe" rather than pass for requests I need to go to the back-end. When using "pass/hit_for_pass" certain browsers (Safari in iPhone, Firefox in XP) were still unable to add items to the cart via AJAX - not sure why, and don't care to spend time figuring it out.

    Using "pipe" may seem inelegant, but it proved to be a good solution to the problems that WordPress + Woo provide.

    A few tips:

    • Pipe all POSTs to the back-end
    • Pipe all AJAX requests to the back-end
    • Pipe all requests back-end if "wp_logged_*" cookie is set (otherwise logged-in users can pollute the cache with the "Howdy, Admin" banner when viewing pages on the site).
    • If you want the "View Cart" link to display cart contents on every page, this must be done via AJAX. Just load a cachable "View Cart" link (that doesn't include # items or $ of cart contents), then fetch their cart contents and update per-user.
    • You should be able to strip cookies on pretty much everything else
    • add this to your VCL any time you use pipe:
      sub vcl_pipe {
        set bereq.http.connection = "close";
      }

    HTH

Reply

You must log in to post.

About this Plugin

About this Topic

Tags