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 (CPG Cloudways Guide) 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_

Sample:



2. Optional Rules for WordPress

Type

Method

Value

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

Send and Receive Emails using Your Domain without an Email Server (Cloudways/Vultr/Runcloud/ServerPilot).

Staff-Pick Promo Codes

*These discount codes are shared by Glitch Deals Hero, our sister site from another neanderthal great grandfather twice removed.

Leave a Reply to Silveryhat Cancel reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


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