Proper Varnish settings for Woocommerce WordPress site running on Cloudways

Cloudways’ Varnish cache is sometimes a little too “sticky” for hers, especially under the Woocommerce environment without the correct exclusions. Most of us who are using Cloudways as our hosting service will certainly come across a handful of annoying issues that could turn a sale away; such as the top right icon cart count doesn’t update when adding or removing an item, persistent empty cart, users unable to login or check out, shipping cost does not calculate, etc…

To fix those problems, carefully apply these rules for your Varnish cache from Cloudways platform panel. Be sure you already have Varnish enabled and properly configured for WordPress (Varnish setting for W3TC).

1. Exclusion Rules for Woocommerce

Application Settings > Varnish Settings > Add New Rules

Type

Method

Value

URLExclude\?add-to-cart=
URLExclude^/(cart|my-account/*|checkout|wc-api/*|addons|logout|lost-password|product/*|wp-admin|wp-login)
CookieExcludewoocommerce_cart_hash
CookieExcludewoocommerce_items_in_cart
CookieExcludewp_woocommerce_session_


2. Optional Rules for WordPress

Type

Method

Value

CookieExcludewp-settings-\d+=[^;]+(; )?
CookieExcludewp-settings-time-\d+=[^;]+(; )?
CookieExclude
wordpress_test_cookie=[^;]+(; )?
CookieExcludewordpress_logged_in

How to Send and Receive Emails using Your Own Domain with Cloudways


Leave a Comment.

Your email address will not be published. Required fields are marked *


2 Comments
  1. December 26, 2017
    • December 29, 2017