Skip to main content
Zass Tech
Free audit
Web Development6 min read

How to Cache a WooCommerce Store Without Breaking Cart and Checkout

By Shakh Farid·November 18, 2026·0 views
#WooCommerce#Page Cache#W3 Total Cache#LiteSpeed Cache#Website Speed

Short answer: Cache every page a logged-out visitor sees the same way (home, shop, categories, products, blog). Never cache cart, checkout, my-account or any page with personal data. Skip the cache entirely for visitors who carry WooCommerce cart or session cookies. Then test all three states: an anonymous visitor should get a cached page, a shopper with items in the cart should get a fresh one, and checkout should never be cached.

Why WooCommerce caching goes wrong

A page cache saves the HTML of a page and sends the same copy to the next visitor. That's perfect for a product page. It's a disaster for a page that's different for each person.

On a WooCommerce site, three things make pages personal:

  1. The cart. Its contents, and often a cart count in the header.
  2. The session. WooCommerce starts a session as soon as someone adds to cart, and the checkout form carries security tokens (nonces) tied to it.
  3. Logged-in customers. Their name, account links and saved addresses.

Cache any of these and you get bugs that are hard to reproduce: a customer sees "3 items in cart" when theirs is empty, checkout says "your session has expired," or worse, one customer sees another's details.

The exclusions I use

This is the setup I run on a live Bangladeshi stationery store. The labels below are from W3 Total Cache; other plugins use different names for the same settings.

Pages that must never be cached

URLWhy
/cart/Different for every visitor
/checkout/Customer details and nonces
/my-account/ (and everything under it)Private account data
Order tracking or any lookup pageShows a specific customer's order
wp-admin, wp-login.php, any wp-*.phpNot public pages

WooCommerce marks cart, checkout and account pages as "do not cache," and many cache plugins respect that automatically. Don't assume yours does. Add the URLs to the exclusion list anyway; it costs nothing.

Cookies that switch the cache off for that visitor

CookieSet when
woocommerce_items_in_cartThe cart has at least one item
woocommerce_cart_hashThe cart contents change
wp_woocommerce_session_ (prefix)WooCommerce starts a session for the visitor

With these in the "rejected cookies" list, a shopper who adds a product gets uncached pages from that point on, so the cart count and any cart-dependent content are always correct. Logged-in users should be excluded too; most plugins do that by default.

Query strings

Don't cache URLs with ?add-to-cart=, and be careful with filter and sort parameters. If your plugin has an option to cache query-string pages, leave it off unless you know which parameters are safe.

Cookie bypass or cart fragments?

There are two ways to keep the cart count correct on cached pages:

  • Cookie bypass (what I used). Visitors with a cart get uncached pages. Simple and reliable. The cost is that active shoppers put more load on the server, but they're the visitors you most want to serve well.
  • Cart fragments. The page is cached for everyone, and a small AJAX request fills in the cart count after loading. This saves server load but adds a request on every page, and if the AJAX call fails, the header shows the wrong count.

For a small or mid-sized shop on shared hosting, cookie bypass is the safer default. Anonymous visitors and bots, which are most of your traffic, still get cached pages.

🎯
Zass Tech service
Google Ads Management

Full-funnel campaign management, from setup to scaling spend profitably.

→

Choosing the cache method

  • W3 Total Cache: use Disk: Enhanced. It writes rules into .htaccess, so the web server returns cached files without starting PHP. "Disk: Basic" still runs PHP for every request.
  • LiteSpeed Cache: on a LiteSpeed server, this is the best option. The server itself handles the cache, and the plugin ships with WooCommerce-aware defaults. Check the exclusions anyway.
  • Other plugins such as WP Rocket or WP Super Cache detect WooCommerce and exclude core pages. Review their lists against the tables above, especially for custom pages like order tracking.

Use one page cache plugin. Two will fight over advanced-cache.php and .htaccess, and you'll get unpredictable results.

How to test it (do all three)

Testing takes five minutes. Use a private browser window so you're logged out.

1. Anonymous visitor gets a cached page. Open the homepage twice. With W3 Total Cache, view the source and scroll to the bottom. You should see Page Caching using Disk: Enhanced and a "Served from" line.

2. Shopper with a cart gets a fresh page. Add any product to the cart, then reload the homepage. The comment should now say the cookie was rejected, and the header count should match the cart.

3. Checkout is never cached. Open checkout. The comment should say the URI was rejected.

On the store I work with, the three comments read exactly:

Page Caching using Disk: Enhanced
Page Caching using Disk: Enhanced (Cookie is rejected)
Page Caching using Disk: Enhanced (Requested URI is rejected)

That's the result you want: cached for strangers, live for shoppers, never for checkout.

Settings disappear more often than you'd think

Two times on the same store, the cache was "installed" but not running:

  • Once because the page cache had been switched off and a leftover advanced-cache.php from an old plugin was in the way. That got the hosting account suspended for CPU overuse (the full story).
  • Once after a hosting migration, when the cache settings came back from an older copy of the files (what to check after a migration).

So repeat the three tests after any migration, restore, or big plugin change.

FAQ

Should I cache the WooCommerce cart page?

No. The cart page is different for every visitor. Exclude /cart/, /checkout/ and /my-account/ from your page cache.

Why does my mini-cart show the wrong number of items?

The page with the header was cached while the cart was empty (or full), and other visitors get that copy. Either skip the cache for visitors with WooCommerce cart cookies, or load the cart count with AJAX after the page loads.

Which cookies should WooCommerce exclude from page cache?

woocommerce_items_in_cart, woocommerce_cart_hash and anything starting with wp_woocommerce_session_. Also exclude logged-in users.

Is W3 Total Cache good for WooCommerce?

It works well if you use Disk: Enhanced page caching and set the exclusions correctly. On a LiteSpeed server, LiteSpeed Cache is usually the better fit.


Settings and test output from a live Bangladeshi stationery e-commerce store. If your WooCommerce site is slow or unstable under traffic, my web development service covers caching and performance fixes.

📊
Zass Tech service
GA4 & GTM Setup

Clean, accurate tracking infrastructure that reports numbers you can trust.

→

Found this useful?

Share it with someone who's fighting the same tracking headaches.

Shakh Farid

Written by

Shakh Farid

Founder, Zass Tech

More from Shakh →