On a WooCommerce store, LiteSpeed Cache for WordPress splits your URLs into three groups, not two. Catalog pages — shop, category, product — should be served from cache with PHP never starting. Cart, checkout, my-account, ?add-to-cart= and the WooCommerce Store API must never be stored at all. The third group is the one that causes the support tickets: catalog pages that are perfectly cacheable but contain a per-shopper fragment, usually the mini-cart in the header. LSCWP already handles most of this on its own, and the fastest way to break a store is to reconfigure what the plugin was already doing correctly. This article sets the boundary explicitly, explains the vary mechanism that keeps two shoppers apart, and gives you the curl checks that prove it.
What you’ll accomplish
- A store where
/shop/, product and category pages returnx-litespeed-cache: hitfor anonymous visitors, with no PHP process involved. - Cart, checkout, my-account, the add-to-cart query string and the Store API cart routes excluded from cache in a way you can verify from the command line.
- A mini-cart that shows the right number of items on a cached page, either through WooCommerce cart fragments or through ESI, with an honest account of which one your server can actually do.
- Purge rules that keep price and stock accurate without shortening your public TTL to the point where the cache stops paying for itself.
- A short verification routine you can re-run after every plugin update or theme change.
Prerequisites
- WordPress 6.4 or newer with WooCommerce 8.0 or newer, and the LiteSpeed Cache plugin at version 6.x or newer. The WooCommerce settings tab described here has been in the plugin since version 3.0.
- A LiteSpeed-family web server. On cPanel that is normally LiteSpeed Web Server Enterprise, installed through WHM. OpenLiteSpeed also runs LSCWP and caches pages, but it does not assemble ESI blocks — that difference decides which mini-cart strategy you can pick, and it is covered in LiteSpeed Enterprise vs OpenLiteSpeed.
- Shell access to the account and WP-CLI available. On cPanel, Terminal in the control panel is enough.
- Write access to the document root
.htaccess. LSCWP writes its rewrite rules there and will silently do nothing if the file is not writable. - Somewhere to test. Everything below can be done on a live store, but the ESI change in particular is worth staging first.
How it works
LiteSpeed caches at the web server, in front of PHP. When a request arrives, the server builds a cache key from the URL, the query string and a small set of cookies, then looks for a stored copy. If it finds one, it writes the bytes back and the request is over — WordPress never loads, WooCommerce never boots, no database connection is opened. That is where the speed comes from, and also where the danger comes from: whatever was baked into the stored copy is what every matching visitor receives.
Three mechanisms decide which branch a request takes.
Exclusions. Under LiteSpeed Cache in WP Admin, the Cache section has an Excludes tab with Do Not Cache URIs, Do Not Cache Query Strings, Do Not Cache Cookies, Do Not Cache Roles and a few others. A match on any of these means the response is neither served from cache nor stored. LSCWP populates the WooCommerce paths automatically when it detects the plugin, which is why most stores are safe out of the box. Trouble starts when a store uses non-default endpoint slugs, a custom checkout page, or a headless front end talking to the Store API.
Vary. For URLs that are cacheable, LiteSpeed still needs to hold more than one version. It does this with a vary cookie. LSCWP writes a cookie named _lscache_vary from PHP, and the server folds that cookie’s value into the cache key. Logged-in state, commenter state, user role and WooCommerce cart state all feed into that single value. Two browsers with different _lscache_vary values get two separate cache entries for the same URL; a browser with no such cookie gets the anonymous entry. This is the part people misread: WooCommerce’s own cookies — woocommerce_items_in_cart, woocommerce_cart_hash, wp_woocommerce_session_* — do not change the cache key by themselves. They are inputs that LSCWP reads before deciding what to put in _lscache_vary. If you have replaced the plugin’s cart handling with your own, that chain can break, and the symptom is a shopper seeing someone else’s header.
ESI. Edge Side Includes let a cached page contain a placeholder that the server fills in per request. LSCWP uses this for the admin bar, the comment form, and — with the WooCommerce integration — the cart totals block. The page stays public and cached; the mini-cart is fetched separately and can carry its own private cache entry. ESI is assembled by LiteSpeed Web Server Enterprise and by QUIC.cloud. OpenLiteSpeed does not do it. If you are on OpenLiteSpeed, the ESI panel in LSCWP will not help you and you should rely on WooCommerce’s own cart fragments instead, which refresh the mini-cart over AJAX after the cached page has loaded.
The trade-off worth naming up front: every additional vary dimension multiplies your cache. Varying by cart state is necessary. Varying by user role on a store where every logged-in customer sees identical prices just splits your hit rate for nothing.
Step-by-step
1. Confirm you are actually on LiteSpeed. A surprising number of “LSCWP is not caching” tickets are Apache or nginx servers running the plugin, where LSCWP can still do minification but cannot page-cache.
curl -sI https://example.com/ | grep -i '^server:'
Expected output:
server: LiteSpeed
If you see Apache or nginx, stop here — nothing below applies until the server is switched.
2. Confirm both plugins are active and note their versions.
wp plugin list --status=active --fields=name,version | grep -E 'litespeed-cache|woocommerce'
Expected output — two rows, with the LiteSpeed plugin at 6.x or newer:
litespeed-cache 6.5.4
woocommerce 9.4.2
3. Check that the rewrite rules are in place. LSCWP writes a LiteSpeed block into the document root .htaccess. Without CacheLookup on, the server never consults the cache no matter what the plugin says.
grep -n -A3 '<IfModule LiteSpeed>' ~/public_html/.htaccess
Expected output — a block containing the lookup directive:
118:<IfModule LiteSpeed>
119:CacheLookup on
120:</IfModule>
If the block is missing, toggle the cache off and on again in LiteSpeed Cache under General, which rewrites the file.
4. Verify the exclusion list. In WP Admin, open LiteSpeed Cache, then Cache, then the Excludes tab. Do Not Cache URIs should contain the cart, checkout and account paths as your store actually spells them. If you renamed pages, or your locale uses translated slugs, the defaults will not match:
/cart
/checkout
/my-account
/wc-api/
/wp-json/wc/store
Under Do Not Cache Query Strings, add add-to-cart. This one matters more than it looks. A request to /product/mug/?add-to-cart=42 has a side effect — it puts an item in the cart — and LiteSpeed treats the query string as part of the cache key, so without the exclusion the server can answer a second shopper’s add-to-cart from a stored copy and the item never lands in their cart.
Do not add /wp-json as a blanket exclusion. That would also block the block editor and any REST-driven feature in your theme. Exclude the Store API cart routes specifically.
5. Set the WooCommerce integration deliberately. Open the WooCommerce tab in the LiteSpeed Cache settings. The two settings that matter here are Privately Cache Cart, which should stay on so returning shoppers get a private copy of cart-bearing pages rather than a full bypass, and Product Update Interval, which controls purging on stock changes. Choose the option that purges the product and its categories when the stock status changes if your category pages display stock badges; choose the product-only option if they do not. The difference is real load: on a store with a few thousand SKUs and hourly stock syncs, purging categories on every quantity change can keep your archive pages permanently cold.
6. Set TTLs that match how often the catalog changes. Under Cache, then the TTL tab, the default public TTL is a week. That is fine for a catalog that changes weekly and wrong for one that changes hourly. If your prices move on a schedule, set the public TTL to something below that interval rather than relying on purge alone, and treat purge as the mechanism for unscheduled edits. Keep the private TTL short — ten to fifteen minutes — because that is what backs account and cart pages, and a customer who just placed an order should see it in their order history quickly.
7. Decide the mini-cart strategy. On LiteSpeed Web Server Enterprise or behind QUIC.cloud, enable ESI under Cache, then the ESI tab, and turn on Cart Totals Followed by ESI in the WooCommerce tab. The catalog page then stays public and cached while the totals block is assembled per request. On OpenLiteSpeed, leave ESI off and make sure your theme still enqueues WooCommerce’s cart fragments script, which updates the mini-cart client-side after load. Themes that dequeue wc-cart-fragments for speed will show a stale item count on every cached page — that is the trade you are making.
8. Purge and re-prime.
wp litespeed-purge all
Expected output — a success line from WP-CLI confirming the purge, after which the next request to any catalog URL will be a miss.
Validate it works
Run these against the live hostname. The first two establish that caching works at all; the rest establish the boundary.
Catalog pages cache. Request twice — the first primes, the second should hit.
curl -sI https://example.com/shop/ | grep -i x-litespeed-cache
curl -sI https://example.com/shop/ | grep -i x-litespeed-cache
Expected output:
x-litespeed-cache: miss
x-litespeed-cache: hit
Transactional pages never cache. Request the cart page repeatedly.
for i in 1 2 3; do curl -sI https://example.com/cart/ | grep -i x-litespeed-cache; done
Expected output — either three miss lines, or no output at all. Both are correct: when a URI is on the Do Not Cache list, LiteSpeed may omit the header entirely. What must never appear is hit. Repeat for /checkout/ and /my-account/.
Add-to-cart is never served from cache.
curl -sI 'https://example.com/product/mug/?add-to-cart=42' | grep -i x-litespeed-cache
Expected output — a miss line or no header. A hit here means the query-string exclusion is missing.
The Store API cart route is never cached.
curl -sI https://example.com/wp-json/wc/store/v1/cart | grep -i x-litespeed-cache
Expected output — no header, or miss. A hit on this route is the modern version of the stale-cart bug, and it affects any store using WooCommerce block checkout.
The real test is two browsers. Open a private window, add an item, and confirm the header shows it. Open a second private window on a different device or with cookies cleared, load the same category page, and confirm the mini-cart reads zero. Header counters are the thing that leaks; no curl invocation reproduces this as convincingly as two sessions side by side.
Troubleshooting
A shopper reports seeing someone else’s cart. This is a vary failure, not an exclusion failure — the URL involved was one you meant to cache.
Two causes account for almost all of them. Either the page was cached by a crawler or a first visitor before any WooCommerce cookie existed and the mini-cart was rendered server-side into that copy, or a custom add-to-cart path updates the cart without going through the WooCommerce hooks LSCWP listens to, so _lscache_vary is never updated. Purge everything, reproduce with two clean sessions, and if it recurs, put woocommerce_items_in_cart into Do Not Cache Cookies as a stopgap. That bypasses cache for anyone with a cart — slower, but correct — while you fix the underlying path.
Product pages show the old price after an edit. Purge on publish covers the product itself but may not cover every archive that lists it. Check the Purge tab’s auto-purge rules, and remember that a very long public TTL plus incomplete purge rules is a bad combination for a catalog with frequent price changes. If a price feed writes directly to the database rather than through WooCommerce’s API, no WordPress hook fires at all and nothing purges — add an explicit wp litespeed-purge all to the end of that import job.
Cart page returns a hit despite being on the exclusion list. Check the entry spelling against the real URL, including whether your permalinks add a trailing slash and whether WPML or Polylang prefixes the path with a language code. /panier and /cart are different strings. Also check for a CDN in front: if Cloudflare or another edge is configured to cache everything, it can store a checkout response before LiteSpeed’s headers are honoured. Set an explicit bypass rule at the edge for the same paths.
Mini-cart always shows zero on cached pages. Expected, if ESI is off and cart fragments are dequeued. Do not fix this by excluding the shop archive from cache — that throws away the entire benefit. Either enable ESI, on a server that supports it, or restore the fragments script.
ESI is enabled but blocks render as empty. Confirm the server flavour. On OpenLiteSpeed the ESI markup is passed through untouched, so the block simply never fills. Check the server header as in step 1, and if you are behind QUIC.cloud, confirm the domain is actually routed through it rather than resolving straight to origin.
When this is the wrong approach
Page cache is the wrong lever for a store whose slowness is in the admin, in checkout itself, or in a product query that takes seconds. None of those are cached paths, and tuning exclusions will not move them. Those are database and object-cache problems — start with choosing a persistent object cache instead.
It is also the wrong approach for a store where every visitor sees different prices: B2B catalogs with per-customer pricing, wholesale tiers, or geo-priced storefronts. You can vary by role, but once the number of distinct price views approaches the number of customers, the cache stores one entry per shopper and hits almost never happen. Those stores get more from a fast origin and a good object cache than from page caching.
Finally, if you are running a marketplace where stock moves every few seconds, a long TTL is a correctness risk rather than a performance win. Accept a short TTL, or exclude the catalog and put your effort into PHP and query performance. LiteSpeed’s own reference for the plugin’s settings is at docs.litespeedtech.com, and WordPress caching APIs are documented at developer.wordpress.org.
Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.