Which caching layer is responsible for stale WooCommerce product data after an update?
0 reputation · 03 May 2025, 02:34 UTC
0 reputation · 03 May 2025, 02:34 UTC
Determine which caching layer (persistent object cache, WooCommerce transients/lookup tables, or CDN/API cache) is serving stale product price or stock data after an update, and understand the safest order to invalidate those layers without triggering a cache stampede.
Constraints include avoiding full‑page cache flushes on high‑traffic stores, accounting for variations in object‑cache drop‑ins, HPOS, and third‑party cache plugins, and ensuring that cart, checkout and account pages remain uncached.
It depends on how the update was written. If the price or stock was changed through the WooCommerce admin, REST API, or any code path that uses the product CRUD objects, WooCommerce fires its invalidation hooks (for example woocommerce_update_product and stock-change hooks), which delete product transients and bump the products cache group. In that case the origin is almost always fresh, and the stale layer is the page cache or CDN edge cache.
If the value was written directly to postmeta — a SQL import, a stock-sync plugin that bypasses CRUD, or a manual database edit — those hooks never fire. Then the stale layer is the persistent object cache and versioned product transients, and often the wc_product_meta_lookup table as well.
One test is decisive: request the product URL with a random query string appended (or view it logged in as admin, which most page caches bypass).
cf-cache-status: HIT, x-cache: HIT, x-litespeed-cache: hit, or a large age value.wp_postmeta and wc_product_meta_lookup rows to see which disagree.Note that with a Redis or Memcached drop-in active, transients are stored in the object cache rather than the options table, so "stale transient" and "stale object cache" are usually the same problem. WooCommerce keys product price transients by a group version, so a version bump invalidates them without deleting anything. Use wp cache get, wp transient list, or your object-cache plugin's diagnostics to inspect the keys, and check Site Health's Drop-ins section to confirm which object-cache.php is actually loaded.
wc_delete_product_transients( $product_id ). If the write path bypasses hooks, purging caches is pointless until that's corrected.Avoid wp cache flush and "purge everything" on a busy store: mass expiry is what causes stampedes. Targeted purges and version bumps regenerate only the touched items. Purging before fixing the origin just re-caches stale data.
WooCommerce provides wc_delete_product_transients(), WC_Cache_Helper::invalidate_cache_group( 'products' ), and the Status → Tools actions for clearing transients and rebuilding lookup tables — none require a full object-cache flush. HPOS does not change product caching (products still live in posts/postmeta; only orders moved). Cart, checkout, and account pages must stay excluded from page and CDN caching regardless.
Hook names, tool labels, and lookup-table behavior vary across WooCommerce versions, and third-party cache plugins add their own purge layers — verify function names against your installed version before scripting anything.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.