Caching WooCommerce HTML at the Cloudflare edge without APO is a two-rule recipe: one Cache Rule that bypasses whenever the visitor has state (a login cookie, a cart cookie, a session), and one that makes everything else eligible for edge cache. Get the bypass conditions exactly right and anonymous catalogue traffic is served from Cloudflare while shoppers with carts hit the origin like the cache never existed. Get them wrong and you cache one shopper’s cart page for everyone — so the bypass rule is the recipe.
What’s happening
By default Cloudflare does not cache HTML at all, so a stock zone never breaks a store — it just doesn’t help it. The moment you make HTML cacheable (“Cache Everything” in old Page Rules terms, “Eligible for cache” in Cache Rules), Cloudflare stores whatever the origin returns, including pages personalized by cookies it knows nothing about. WooCommerce marks its state with three cookie families, and they are the entire key to doing this safely:
wordpress_logged_in_— any authenticated user, admins included.woocommerce_items_in_cart— set to1the moment the cart is non-empty.wp_woocommerce_session_— the shopper’s session, present once they interact with the store.
Two structural safety nets help you: Cloudflare only caches GET/HEAD requests, so the cart-fragments POST (wc-ajax=get_refreshed_fragments) can never be cached; and WooCommerce sends Cache-Control: no-cache on cart, checkout, and account pages. But relying on origin headers alone is fragile — an optimization plugin or misconfigured page cache can overwrite them — so the recipe encodes the exclusions explicitly at the edge as well.
What to check first
- What sends
Cache-Controlfor HTML at the origin today (page-cache plugin, server config)? Edge TTL “respect origin” only works when the origin is telling the truth. - Existing Page Rules or Cache Rules that touch caching — merge into one design, never stack recipes.
- Plan capacity: Cache Rules allow 10 rules on Free, 25 on Pro, 50 on Business — this recipe needs two, three with a belt-and-suspenders static rule.
- Whether APO is the better answer: APO ships these bypasses pre-built and adds device-aware caching for US$5/month on Free (included Pro and up). This recipe exists for when you want the control or not the dependency.
How to verify
Baseline before, then re-run after deploying the rules:
# Anonymous product page: goal is cf-cache-status HIT after warm-up
curl -sI https://www.example.com/product/sample/ \
| grep -iE 'cf-cache-status|age|cache-control'
# With a cart cookie: MUST be BYPASS
curl -sI -H 'Cookie: woocommerce_items_in_cart=1' \
https://www.example.com/product/sample/ | grep -i cf-cache-status
# Logged-in cookie: MUST be BYPASS
curl -sI -H 'Cookie: wordpress_logged_in_abc123=test' \
https://www.example.com/product/sample/ | grep -i cf-cache-status
# Checkout and cart: never HIT, regardless of cookies
curl -sI https://www.example.com/checkout/ | grep -i cf-cache-status
curl -sI https://www.example.com/cart/ | grep -i cf-cache-status
Anything but BYPASS (or DYNAMIC) on the cookie-bearing requests means the bypass rule is not matching — stop and fix before letting the eligibility rule cache another byte.
The fix
- Create the bypass rule first, at the top of the Cache Rules list (Caching > Cache Rules). Rules are evaluated in order; state-bearing traffic must exit before the cache rule sees it. Expression:
(http.cookie contains "wordpress_logged_in_")
or (http.cookie contains "woocommerce_items_in_cart")
or (http.cookie contains "wp_woocommerce_session_")
or (starts_with(http.request.uri.path, "/cart"))
or (starts_with(http.request.uri.path, "/checkout"))
or (starts_with(http.request.uri.path, "/my-account"))
or (starts_with(http.request.uri.path, "/wp-admin"))
or (http.request.uri.path eq "/wp-login.php")
or (http.request.uri.query contains "wc-ajax")
Action: Bypass cache.
- Then the eligibility rule below it, scoped to your hostname: match
http.host eq "www.example.com", action Eligible for cache, Edge TTL “Use cache-control header if present, bypass cache if not” — or a fixed Edge TTL (2 to 4 hours is a sane starting point for catalogues) if you prefer the edge to own the number. - Translate the paths if the store is localized — a Quebec store often runs
/panier,/commander,/mon-compte. The bypass list must match the real slugs, not WooCommerce defaults. - Wire up purging. Without APO you have no automatic purge on product updates unless a plugin does it — the official Cloudflare plugin, WP Rocket’s add-on, or a small hook calling the purge API on
save_postand stock changes. A cache you cannot purge on demand is a liability on a store. - Warm and verify with the curl set above, then click through a real shopper journey in a private window: browse, add to cart, confirm every subsequent page shows
BYPASS.
When this fix is wrong
- Highly personalized stores — logged-in B2B pricing, geo-priced catalogues, currency switchers on cookies you have not listed — leak state through any generic recipe. Every personalization cookie must join the bypass expression, or HTML caching may simply not be worth it.
- If you already pay for Pro, weigh APO first: it solves purging and device-type splits that this recipe leaves to you — the trade-offs live in Cloudflare APO deep configuration.
- If TTFB is fine and conversion problems are elsewhere, HTML edge caching is optimization theatre. Static assets are already cached by default.
Common mistakes
- Putting the eligibility rule above the bypass rule — order decides everything.
- Bypassing on
woocommerce_alone but missingwordpress_logged_in_, then caching an admin’s toolbar for the public. - Forgetting
wc-ajaxin the query condition; most calls are POST, but some themes and plugins issue GETs. - Testing while logged in and reading
BYPASSas “rules work” — of course it bypasses for you; verify the anonymous HIT too. - Letting a page-cache plugin send
Cache-Control: public, max-age=31536000on HTML; with “respect origin” that pins stale pages at the edge for a year.
Prevention
- Keep the three cookie names and the path list in your store’s runbook; review them after WooCommerce major updates and any checkout-flow plugin change.
- Alert on two synthetic checks: anonymous product page must eventually HIT, cookie-bearing request must always BYPASS.
- When adding any plugin that personalizes pages, ask one question first: what cookie does it set, and is that cookie in the bypass rule?
- The broader decision framework — what deserves edge caching on WordPress at all — is in Cloudflare cache rules that pay off and the mechanics reference in Cache Rules and cacheability, with the official behaviour spec in the Cloudflare cache docs.
Done right, this recipe gives a store most of APO’s speed with none of its opacity. Need Cloudflare stabilized in front of a WordPress or WooCommerce site that earns money? Stack Harbor runs that exact stack under Enterprise WordPress — book an infrastructure consult.