Since I enabled page caching, customers report an empty cart or the wrong mini-cart count. How should caching be configured for WooCommerce?
#woocommerce#caching#performance
DEV3 Developer Forum
Every post is reviewed first. Usually reviewed within 24 hours.
Since I enabled page caching, customers report an empty cart or the wrong mini-cart count. How should caching be configured for WooCommerce?
#woocommerce#caching#performance
Cart and session data is per visitor. A full-page cache that serves one stored HTML copy to everyone breaks that.
Never cache these
woocommerce_cart_hash, woocommerce_items_in_cart, wp_woocommerce_session_*.?wc-ajax= and add-to-cart query strings.WooCommerce sends DONOTCACHEPAGE for those pages and most caching plugins respect it, but confirm in the plugin's exclusion list. For server-level caches (Nginx fastcgi_cache, Varnish, Cloudflare page rules), add the rules yourself:
set $skip_cache 0;
if ($request_uri ~* "/(cart|checkout|my-account)/") { set $skip_cache 1; }
if ($http_cookie ~* "woocommerce_items_in_cart|wp_woocommerce_session|wordpress_logged_in") { set $skip_cache 1; }
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
Mini-cart fragments: WooCommerce refreshes the cart count with an AJAX fragments request, so the rest of the page can stay cached. Do not disable cart fragments unless your theme updates the count another way.
Object cache (Redis or Memcached) is safe and helps a lot: it caches database results, not whole pages.
Pitfalls