WooCommerce Cache Errors and How to Prevent Them

The causes of cart, session and checkout cache errors in WooCommerce; the right exclusions for page cache, Cloudflare and Redis, and a testing method.
Technical summary
Technology
WooCommerce, page cache, Cloudflare, Redis
Topic
E-commerce caching problems
Level
Intermediate
In this article5 sections

A customer adds a product to the cart, the page refreshes and the cart appears empty. Or worse: another customer’s name and address are on the checkout page. In WooCommerce, almost all of these symptoms come down to a single root cause: a personalized page being stored in one of the cache layers as if it were a public page. This guide covers the cache errors we come across most often in the field, their causes and the correct configuration at the page cache, Cloudflare and Redis layers.

Why does it happen so often?

A store has two kinds of pages at the same time: pages that look the same to everyone (home, category, product) and personalized pages (cart, checkout, my account). Cache layers — plugin-based page cache, server cache (nginx FastCGI cache, Varnish, LiteSpeed) and CDN — don’t know this distinction on their own. They have to learn which requests are personalized from URL and cookie rules. If even one of the layers is misconfigured, the error appears.

On its side, WooCommerce sends headers that prevent caching on the cart, checkout and my account pages and defines the DONOTCACHEPAGE constant. Most cache plugins respect this constant. The problem usually starts at a higher layer: a CDN rule that ignores origin headers, an nginx configuration that doesn’t take cookies into account, or a reverse proxy set up with “cache everything” logic. The plugin may be working correctly. The layer in front of it overrides it.

The second common cause is layers being set up without knowing about each other. When a plugin cache, a server cache and Cloudflare APO are all enabled at once, nobody knows where a given response came from; purging is done on only one, and the other two keep serving old content. The first thing we do in the field is put on paper every layer a request passes through and each layer’s rules.

Common errors and their causes

Symptom Likely cause Fix
Another user’s cart or name is shown Session requests have been cached on the CDN or server Bypass requests with WooCommerce and session cookies on all layers
Old price/shipping on the checkout page The checkout page is cached Exclude /cart, /checkout, /my-account and their endpoints
Add to cart doesn’t work, the cart count doesn’t update A page containing a nonce is cached for a long time; the AJAX/fragments request has been cached Keep cache lifetime in line with the nonce lifetime, bypass wc-ajax requests
An out-of-stock product shows as “in stock” The product page isn’t purged when stock changes Purge the related URLs on stock/price updates
Order status is wrong on return from payment The payment provider’s callback URL is cached or blocked by the WAF Exempt callback endpoints from cache and WAF rules

The first row in the table is the most dangerous, because it’s not a performance problem but a data leak. If a cached response also carries a Set-Cookie header, one visitor’s session cookie is handed out to subsequent visitors and everyone ends up in the same cart. When you see this symptom, the first thing to do is turn off page caching completely, then switch the layers back on one by one to find the cause. Stop the bleeding first.

Another overlooked source is multilingual and multi-currency stores. If the language or currency is chosen via a cookie and the cache doesn’t include that cookie in its key, a visitor opening the Turkish page may get the English page, or prices in euros instead of TL. The same thing happens with WooCommerce’s tax calculation by geolocation; for this scenario, WooCommerce settings have a “Geolocate (with page caching support)” option that separates the cache key by adding a location parameter to the URL.

Correct configuration: layer by layer

Page cache (plugin or server)

  • Cart, checkout and my account pages are excluded (along with their equivalents in your language and permalink structure).
  • The cache is bypassed if any of the woocommerce_items_in_cart, woocommerce_cart_hash, wp_woocommerce_session_* or wordpress_logged_in_* cookies is present.
  • ?add-to-cart= and wc-ajax requests aren’t cached.
  • Cache lifetime is kept shorter than the WordPress nonce lifetime (12–24 hours by default), or the cache is refreshed regularly.

If you use nginx FastCGI cache instead of a plugin, you have to write these rules yourself: a $skip_cache variable is set based on the request URI and cookies, then both reading and writing are blocked with the fastcgi_cache_bypass $skip_cache; and fastcgi_no_cache $skip_cache; lines. The mistake we see most often in the field is writing only the bypass line. In that case, a logged-in user doesn’t read from the cache but does write the response to it; the next anonymous visitor sees that person’s page. Both lines are needed together.

Mini cart components added from page builders (Elementor, block themes) also need attention. If the component embeds the cart count in the page HTML, the cached page carries the old count. The cart count should come with a separate dynamic request (fragments or a block-based mini cart).

Cloudflare

  • If HTML caching is used (Cache Rules / APO), a “bypass” condition is defined for WooCommerce and session cookies.
  • Payment provider callback URLs and REST API endpoints are exempted from the cache and aggressive WAF rules.
  • A “Cache Everything” rule isn’t applied unconditionally.

When caching HTML with Cache Rules, setting the Edge TTL to ignore the origin’s Cache-Control headers also means throwing away the “don’t cache” signal WooCommerce sends. If this setting is used, the cookie and path exceptions must be explicitly defined inside the rule. Rule order matters too; if the bypass rule is evaluated after a broad cache rule, it won’t give you the result you expect.

The notification (webhook/callback) requests the payment provider sends server-to-server aren’t browsers. If Bot Fight Mode, a JavaScript challenge or country-based blocking stops these requests, the payment is taken but the order stays “pending”. Skip the callback path in WAF rules, and if the payment provider publishes an IP list in its documentation, restrict to it.

Object cache (Redis)

Redis speeds up pages that can’t be page-cached and can be used safely; session data is managed by WooCommerce’s own mechanism. The memory limit and eviction policy should be set. For how the layers work in general, see the Cloudflare, WP Rocket and Redis guide.

In practice, the maxmemory value is limited according to server memory and an eviction policy such as allkeys-lru is chosen; if no limit is defined, Redis grows and squeezes the memory of PHP-FPM and MariaDB. If several sites share the same Redis instance, each site should use a separate prefix or database number. Otherwise one site’s purge empties the other too, and worse, keys collide.

Test scenario

In tests, trust response headers, not the browser. With curl -sI https://domain/product/example/, read cf-cache-status, x-cache or the header your cache layer adds; when the same request is repeated with -H "Cookie: woocommerce_items_in_cart=1", the response should come back uncached. If the second request also returns a HIT, the cookie exclusion isn’t working.

  1. Open a product page in a private window; see HIT in the cache header.
  2. Add a product to the cart; verify that the cart count updates and that subsequent pages come back uncached (BYPASS/MISS).
  3. Open the same page in a different browser; verify that the first user’s cart isn’t shown.
  4. On the checkout page, check that coupon and shipping changes are reflected immediately.
  5. Make a test payment; verify that the order status and emails are correct.
  6. Change stock from the admin panel; check that the product page is updated.

These tests should be repeated after every plugin or cache setting change. In addition, HPOS (High-Performance Order Storage) compatibility for order tables reduces database load in large stores.

Don’t leave testing until right before a campaign. A cache error that appears under heavy traffic means lost sales and lost customer data; when you have to turn off the cache to roll back, the server comes under load at the same time. Try changes in a test environment with the same cache layers as live.

Frequently asked questions

Why does the cart counter show the wrong number?

If the page comes from the cache, the cart count may show the value from the moment it was cached. Cart fragments or a block-based mini cart should be loaded dynamically, and these requests shouldn’t be cached.

Can product pages be cached?

Yes; product and category pages can be cached for anonymous visitors. When stock and prices change, the relevant page should be purged; if there’s customer-specific pricing (B2B), the cache should be bypassed for logged-in users.

Does Redis speed up WooCommerce?

Yes; it reduces database load especially on pages that can’t be page-cached, such as the cart, checkout, my account and the admin panel. But it doesn’t fix the slow query itself.

To set up your store’s cache and performance configuration together, see our WooCommerce e-commerce and WordPress cache and CDN optimization services.

Support

Contact us for support or a discovery session on this topic.

Contact form
[email protected]

Eretek Web

We build and maintain corporate websites, WordPress and CMS platforms, intranet and SharePoint portals, document management, and form and approval workflows, and keep them secure and up to date.

Knowledge Center

Other articles