Admin shows 0 stock, but the frontend still says In Stock — customers are placing orders for items you don’t have, and you may not notice until customers complain. If you’ve already checked WooCommerce or Magento and confirmed the admin panel is showing the correct stock level, the database isn’t the problem. Almost every time, a cache is showing an old copy.
Here’s the direct answer: when admin stock is correct but the frontend shows wrong data, a cache layer is almost always serving an old copy: Full-Page Cache (FPC), Object Cache (Redis/Memcached), WooCommerce transients or a CDN. Most of these do not clear themselves when stock changes unless your caching plugin or code tells them to. Fix: find the layer from the response headers, purge it, then make stock changes trigger that purge, or load the stock figure with AJAX so the cached HTML does not carry it.
Flushing “all cache” once doesn’t tell you which layer caused the mismatch. You could be dealing with Varnish, Nginx FastCGI Cache, LiteSpeed Cache, Browser Cache, a CDN edge cache, or a Transient Cache that hasn’t expired because its TTL (Time to Live) is set to several hours. Treating all of these as one thing is why the problem keeps coming back.
Below is a layer-by-layer diagnosis and fix for WooCommerce and Magento/Adobe Commerce, so you can find which layer holds the old stock and clear it the right way.
What Is Actually Going Wrong — Why Admin Shows the Right Stock but Frontend Shows the Wrong One
Admin pages are never served from a page cache, so when you update stock to 3 units, the admin shows 3 units straight away. The frontend is a different story. It goes through several layers between the database and the browser, and any one of them can be serving a snapshot of your stock from an hour ago, or longer.

How Cache Creates Stock Mismatch (Full-Page Cache vs Object Cache vs CDN)
Three cache layers can independently cause a stock mismatch, and most sites have two or three of them active; a fourth, MySQL’s query cache, cannot, as explained below.
Full-Page Cache (FPC) is usually the biggest culprit. When a customer visits your product page, FPC (whether that’s Varnish, Nginx FastCGI Cache, LiteSpeed Cache, or a WordPress caching plugin) serves a pre-built HTML snapshot of that page. That snapshot was generated at some point in the past — sometimes minutes ago, sometimes hours — and it contains the stock number from that moment. Your actual database says 0. The cached HTML still says “In Stock — 14 available.” The TTL (Time to Live) on that cache entry determines how long the old number stays.
Object Cache (typically Redis or Memcached) operates at the PHP/application layer. The stock number itself lives in product meta and the wc_product_meta_lookup table, but WordPress caches product posts and meta in the object cache, and WooCommerce keeps computed lists, such as a variable product’s children, in transients. If those are not cleared on a stock change, they can go stale. A stale Object Cache entry can feed wrong stock data into the page-building process even before FPC gets involved. So your page cache might be fresh, but the stock number baked into it was already wrong.
CDN and Edge Cache sit furthest from your server. Services like Cloudflare, Fastly, or BunnyCDN cache product page responses at edge nodes distributed globally. A customer in Singapore might be reading a cached page from an edge node that last fetched your product page six hours ago. Even after you manually purge your server-side caches, the edge cache can hold stale responses for its own TTL window. Cloudflare does not cache HTML unless a rule tells it to; when one does, the edge TTL is whatever that rule sets.
Database Query Cache (MySQL’s built-in query cache) cannot serve stale stock, as its own section below explains, so you can rule it out early.
These layers are independent. Purging your FPC does nothing to your CDN edge cache. Clearing Redis does nothing to your browser cache. A complete fix requires addressing every layer that’s active on your stack.
Smart Cache vs Regular Cache — Where the Difference Matters for Stock Data
“Regular” cache treats every page response the same way: cache it for X minutes, serve the cached version to everyone, then expire. That works fine for purely static content. For stock data it fails, because stock changes on every purchase.
“Smart” caching systems try to handle this by making specific pages or content types exempt from caching, or by triggering a cache purge when something changes. WooCommerce-aware caching setups (LiteSpeed Cache with its WooCommerce integration enabled, for example) know to exclude cart pages, account pages, and in some configurations, product pages when stock changes. But “smart” doesn’t mean perfect.
The specific place this matters for stock:
- Cache Exclusion Lists — well-configured caching plugins let you exclude individual URLs or page types. Product pages can be excluded, but stores usually avoid this because it kills performance. The more common approach is to exclude only the stock-display fragment via AJAX and cache the rest of the page.
- Cache Purge Triggers — WooCommerce fires hooks like
woocommerce_product_set_stockandwoocommerce_variation_set_stockwhen stock changes. A smart caching layer hooks into these to purge the relevant cached page. If your caching plugin doesn’t integrate with these hooks, it won’t know that a stock update happened, and the purge never fires. - AJAX-loaded stock — the cleanest architectural solution is to cache the full page but load the stock number dynamically via a separate AJAX request that bypasses cache entirely. WooCommerce’s own “N in stock” text doesn’t do this out of the box — you get a static number baked into the HTML at page-generation time.
Magento / Adobe Commerce handles this more explicitly with its FPC implementation. Customer-specific data loads separately through private content (customer sections) while the rest of the page stays in FPC.
Before you blame a cache, rule out two causes that are not caches. First, regenerate WooCommerce’s product lookup tables under WooCommerce → Status → Tools (“Regenerate the product lookup tables”): if they are stale, “hide out of stock”, sorting and filters can be wrong while the product’s stock in admin is right. Second, for a variable product, check whether stock is managed on the parent or on each variation, because the shop shows the level the product is set to use.
How to Identify Which Cache Layer Is Causing the Problem
Work through this systematically. Don’t guess — each step rules out one layer.
Step 1 — Check the response headers first. Open your browser’s DevTools (F12), go to the Network tab, reload the product page, and click the main HTML document request. Look for headers like X-Cache, CF-Cache-Status, X-Varnish, X-LiteSpeed-Cache, or Age. An Age: 3600 header means the response is being served from cache and is 3600 seconds (one hour) old. CF-Cache-Status: HIT means Cloudflare is serving a cached copy. This single step often tells you immediately whether the CDN or server-level FPC is involved.
Step 2 — Test with cache bypass. Add a cache-busting query string to the URL: ?nocache=1 or ?v=123. A new query string is usually a new cache key, so the first request with it goes to the server; some setups ignore query strings, so use a value you have not used before. If the stock number changes to the correct value with the query string appended, the problem is in your FPC or Edge Cache layer.
Step 3 — Test from incognito and a different network. Browser Cache can persist stale data locally. An incognito window clears browser-side storage. A different network (your phone’s mobile data) bypasses any location-specific CDN edge node that might be caching a stale copy.
Step 4 — Check your Object Cache directly. If you’re running Redis or Memcached, connect to Redis CLI and run:
redis-cli --scan --pattern "*wc_*"
Look for WooCommerce product-related keys. You can also temporarily disable your Object Cache plugin (like Redis Object Cache or W3 Total Cache’s object cache module) and reload the product page. If the correct stock appears, Object Cache is your layer.
Step 5 — Check WooCommerce transients. In your database, query:
SELECT option_name, option_value FROM wp_options
WHERE option_name LIKE '_transient_wc_product_%'
ORDER BY option_name;
Look for transient entries related to your affected product ID. These hold computed lists (for example which variations a product has), not the stock number. If they look outdated after a stock change, they are not being cleared. With a persistent object cache, transients are stored there instead of in wp_options.
Step 6 — Look at your Cron Jobs and stock sync timing. If you’re syncing stock from an external system — an ERP, a warehouse management tool, or a multi-location inventory setup — check whether the Cron Job or Webhook that pushes stock updates to WooCommerce is also triggering a cache purge. A lot of Stock Sync integrations update the database correctly but never fire the cache invalidation step, so you get accurate data in the DB but stale data on every cached page until it naturally expires.
Diagnosing and Fixing by Cache Layer
The fix for a Varnish TTL issue is completely different from the fix for a stale Redis object. Before you start clearing things at random, identify which layer is actually holding the stale stock data — then target that layer specifically.

Full-Page Cache (FPC) — Not Invalidating on Stock Changes
FPC is the most common culprit. When a customer buys something, WooCommerce updates the stock in the database. But if your FPC doesn’t know a stock change happened, it keeps serving the old HTML — complete with the old stock number — to every visitor who hits that cached page.
This is a site-wide symptom. Multiple users see the same wrong number. The product page looks exactly as it did before the sale.
How to confirm it: Open the product page in an incognito window on a different device. If the wrong stock appears there too, FPC is almost certainly the problem. Then check your response headers — look for X-Cache: HIT or Age: [number]. A high Age value tells you the page hasn’t been refreshed in a while.
What causes the invalidation to fail:
- Your caching plugin doesn’t hook into
woocommerce_reduce_order_stockorwoocommerce_product_set_stock - The product page URL isn’t in the cache invalidation rules
- Stock updates triggered by a webhook or cron job happen outside the normal WooCommerce order flow, so the cache never gets the signal to purge
Fix — WooCommerce native: WooCommerce adds no-cache headers to cart and checkout pages automatically. Product pages are not covered. You need to make sure your caching plugin is set to purge product pages when stock changes.
In most caching plugins, look for a setting called something like “Cache Invalidation on WooCommerce Events” or “Purge on Product Update.” Enable it and make sure it covers stock changes, not just product edits.
Fix — developer path: If you’re managing cache programmatically, hook into the stock update action and fire your own purge:
add_action( 'woocommerce_product_set_stock', function( $product ) {
$url = get_permalink( $product->get_id() );
// call your cache purge function here, e.g. your CDN or FPC purge API
wc_delete_product_transients( $product->get_id() );
} );
The exact purge call depends on your stack, but the hook is the right place to trigger it.
If you’re running multi-location inventory, with separate stock per warehouse and a different quantity per location, your cache invalidation needs to account for that. A page cached after a customer selected Location A will show Location A’s stock to someone on Location B. Our own Multi-Location Product & Inventory Management for WooCommerce sends a Vary: Cookie header so caches can keep a separate copy per selected location; the multi-location section below has the details.
Object Cache (Redis / Memcached) — Stale Stock Query Results
Object cache sits between WooCommerce and the database. Redis or Memcached stores the results of expensive queries — including stock quantity lookups — so PHP doesn’t hit the database every time.
The problem: those cached query results don’t always expire when stock changes. WooCommerce transients are particularly prone to this. The _transient_wc_product_children_* transients, which list a product’s variations, can sit in Redis after a stock change.
Symptoms: The wrong stock appears consistently, across browsers and devices. Flushing the FPC doesn’t help. But manually deleting the object cache does fix it — temporarily.
Diagnosis: Run redis-cli --scan --pattern "*wc*" or check your Redis management UI for WooCommerce-related keys. Look at their TTL values. If they’re sitting at 3600 seconds or more and you’ve had stock changes in that window, you’ve found your problem.
Fix:
- Go to WooCommerce → Status → Tools and run “Clear transients” in the WooCommerce transients row.
- Avoid deleting Redis keys by pattern on a live store: key names depend on your object cache plugin, and a wrong pattern can remove other data on a shared Redis server. Use the WooCommerce tool above, or your object cache plugin’s flush button.
- If you store custom stock data in transients, keep their expiry short (5–10 minutes) and delete them when stock changes.
The longer-term fix is making sure whatever triggers a stock change also purges the relevant object cache keys. If you’re using a webhook or cron job to sync stock from an external source, end that sync routine with wc_delete_product_transients() and clean_post_cache() for each changed product, as in the code in the WooCommerce section.
Database Query Cache — Stock Data Freshness Problems
MySQL’s built-in query cache was deprecated in MySQL 5.7 and removed in MySQL 8.0; MariaDB still has it, but it is off by default in current versions. It cannot serve stale stock: the server drops every cached result for a table as soon as that table is written to, whatever wrote to it.
Quick check: Run SHOW VARIABLES LIKE 'query_cache_type'; in phpMyAdmin or your DB tool. If it returns ON or DEMAND, query cache is active. Then run SHOW STATUS LIKE 'Qcache_hits'; — a high hit count tells you it’s actually being used.
Fix: Nothing to fix for stock accuracy. If the query cache is on, it only affects speed, so you can rule this layer out and move on to the next one.
CDN Cache — Outdated Stock Responses Served from the Edge
This one is easy to miss because most people think CDNs only cache images and static assets. Some CDN configurations — especially when using Cloudflare’s “Cache Everything” page rule or similar settings on Fastly, BunnyCDN, or KeyCDN — will cache full HTML responses. That means edge nodes in Frankfurt, Singapore, and São Paulo are all serving the same cached product page HTML regardless of what’s in your database.
How to confirm: Check response headers for CF-Cache-Status: HIT (Cloudflare) or X-Cache: HIT from CDN (generic). Also check the Age header — if it’s nonzero on a product page, your CDN is caching it.
Fix — Cloudflare: Either add a Cache Rule that bypasses cache for product pages (URI path contains /product/), or set up a Cache Purge Trigger via Cloudflare’s API whenever stock changes. The API call is simple:
POST https://api.cloudflare.com/client/v4/zones/{zone_id}/purge_cache
Authorization: Bearer <API token>
Body: { "files": ["https://yourdomain.com/product/your-product-slug/"] }
You can trigger this from a woocommerce_product_set_stock action hook on your server.
Fix — general: Most CDNs let you set Cache-Control headers on specific URL patterns. For product pages, set Cache-Control: no-store or a very short max-age (30–60 seconds). Longer-term, keep product pages out of your CDN’s HTML cache entirely and only let the CDN cache your static assets.
Fixing Frontend Stock Mismatch in WooCommerce
WooCommerce stock problems almost always trace back to one of four places: exclusion rules missing a page, stale transients, a cached HTML response that ignores live stock, or a category page that was not cleared when stock changed. Each one has a different fix.

Add WooCommerce Stock Pages to the Cache Exclusion List
Cart, checkout and account pages should never be served from a full-page cache, and most caching plugins already exclude them. Product pages are the judgement call: excluding them is the simplest fix but costs speed, so it suits products whose stock changes fast, such as flash sales, low inventory or several warehouses feeding the same SKU.
Open your caching plugin’s exclusion settings and add URL patterns for these:
/product/— all single product pages/cart//checkout//my-account/
If you’re using LiteSpeed Cache, go to LiteSpeed Cache → Cache → Excludes and add those URI patterns under “Do Not Cache URIs.” For Nginx FastCGI Cache, add a set $skip_cache 1; condition in your server block that matches those paths. Varnish users need to add a vcl_recv rule that returns pass for those URLs.
The problem is that many setups cache /product/ pages aggressively — sometimes with a TTL of an hour or more. A customer who lands on a product page 45 minutes after the last cache purge sees whatever stock count existed at purge time. If 10 units sold in those 45 minutes, they have no idea.
Transient Cache and WooCommerce Stock Sync
WooCommerce uses the WordPress transient API to store some computed data — related products, query results and lists of a product’s variations, but not the stock number itself. These transients have their own TTL, separate from your page cache, and they persist in the database (or in Redis/Memcached if you have object caching configured).
You can clear all WooCommerce transients manually from WooCommerce → Status → Tools → Clear transients. Do that and recheck your frontend. If the correct stock appears immediately after, transients were the culprit.
The real fix is automating that clear. WooCommerce fires woocommerce_product_set_stock when stock changes on a product. You can hook into that to clear specific transients:
add_action( 'woocommerce_product_set_stock', function( $product ) {
wc_delete_product_transients( $product->get_id() );
clean_post_cache( $product->get_id() );
} );
Add this to your child theme’s functions.php or a small site-specific plugin. It fires every time WooCommerce updates stock on a product — whether from an order, a manual admin edit, or an external stock sync, as long as the sync uses WooCommerce’s own stock functions rather than writing to the database directly.
If you use Redis or Memcached as your object cache backend, stale object cache entries can override even a fresh database value. In the hook above, clean_post_cache() clears WordPress’s cached copy of the product post and wc_delete_product_transients() clears WooCommerce’s product transients, which live in the object cache when one is installed. Hook the same function to woocommerce_variation_set_stock for variations.
Use AJAX to Display Stock Dynamically — Cache Bypass Method
Excluding product pages from cache works, but it increases server load. If you want the performance benefits of full-page caching AND accurate stock, AJAX is the cleaner path.
The idea is simple: cache the page HTML normally, but serve the stock display via a separate AJAX request that always hits the server fresh. The initial page loads fast from cache. A small JavaScript call then replaces the cached stock number with the live one.
Here’s a basic pattern:
Enqueue a script that fires on product pages:
add_action( 'wp_enqueue_scripts', function() {
if ( is_product() ) {
wp_enqueue_script( 'live-stock', get_stylesheet_directory_uri() . '/js/live-stock.js', array( 'jquery' ), null, true );
wp_localize_script( 'live-stock', 'liveStock', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'product_id' => get_the_ID(),
) );
}
} );
Register the AJAX handler:
function my_get_live_stock() {
$product_id = isset( $_POST['product_id'] ) ? absint( $_POST['product_id'] ) : 0;
$product = wc_get_product( $product_id );
if ( ! $product || 'publish' !== $product->get_status() ) wp_die();
wp_send_json_success( array(
'stock_quantity' => $product->get_stock_quantity(),
'stock_status' => $product->get_stock_status(),
) );
}
add_action( 'wp_ajax_nopriv_get_live_stock', 'my_get_live_stock' );
add_action( 'wp_ajax_get_live_stock', 'my_get_live_stock' );
Your live-stock.js then calls this endpoint on page load and swaps in the real value. This works even with Varnish, CDN edge cache, or LiteSpeed Cache serving the page — the AJAX request bypasses all of them because it hits admin-ajax.php directly, which is excluded from caching in virtually every setup.
This is also the right pattern if you need to show real-time stock display modes — exact quantities, low-stock labels, or per-location availability — without sacrificing your cache hit rate.
Category Page Cache — Force Invalidation When Stock Quantity Changes
Category pages are the most overlooked cache problem in WooCommerce. A product showing “In Stock” on a shop archive page pulls that status from cached HTML, not from a live database query. Somebody buys the last unit. The product is now out of stock. But the category page cache hasn’t expired yet, so the archive page still shows it as available. Customers click through, hit the product page, and see it’s gone.
So when a product’s stock status changes, the archive pages it appears on need purging too, not just the product page.
Most caching plugins expose a hook or API to purge specific URLs. LiteSpeed Cache has do_action('litespeed_purge_post', $post_id). WP Rocket has rocket_clean_post(). If you’re running Varnish or a CDN with a purge API, you send an HTTP PURGE request to the cached URL.
The hook to watch is woocommerce_product_set_stock_status — it fires when a product’s stock status changes (e.g. from instock to outofstock). When that fires, grab the product’s categories and purge their archive URLs:
add_action( 'woocommerce_product_set_stock_status', function( $product_id, $status, $product ) {
$terms = get_the_terms( $product_id, 'product_cat' );
if ( $terms && ! is_wp_error( $terms ) ) {
foreach ( $terms as $term ) {
$url = get_term_link( $term );
// Fire your cache purge API here for $url
}
}
}, 10, 3 );
What you trigger inside that loop depends on your stack. LiteSpeed Cache users can call the purge action. CDN users with a Webhook-based purge endpoint (Cloudflare, Fastly, BunnyCDN) fire an HTTP request to that endpoint.
Fixing Frontend Stock Mismatch in Magento / Adobe Commerce
Magento’s caching architecture is more layered than WooCommerce’s. You’ve got Full-Page Cache built into core, Varnish sitting in front of it on most production setups, and a separate block cache system on top of that. When stock updates don’t propagate correctly, it’s usually one of these three things: you flushed the wrong cache, an unpatched bug is triggering unnecessary invalidation, or your Varnish TTL is too long for pages where stock actually changes.
The Correct Way to Flush Full-Page Cache
Go to System → Tools → Cache Management. “Flush Magento Cache” clears everything Magento has tagged, including the built-in full-page cache. If you use Varnish, the full-page cache lives in Varnish instead, so Magento has to send it a purge request; check that the request arrives, as covered below.
The right sequence depends on your setup:
Built-in FPC (no Varnish):
- Go to System → Tools → Cache Management
- Check Full Page Cache specifically
- Click Refresh — not “Flush Cache Storage,” which clears everything including config cache and slows your next page load significantly
That’s usually enough for a basic Magento install. Magento clears cached pages by tag when a product is saved, so if a product’s stock changed and the page still shows old stock, the invalidation failed; the TTL (86400 seconds by default) only sets how long a page lives when nothing clears it.
With Varnish:
Magento sends Varnish a PURGE request with an X-Magento-Tags-Pattern header, and the VCL turns it into a ban. This only works if:
- Your
default.vclhas the correct ban logic - The
MAGE_RUN_CODEand host header are configured right - Magento’s Varnish configuration export matches your actual Varnish version (4, 5, 6, or 7 — they differ)
To clear the full-page cache from the command line (Magento then sends the purge to Varnish):
bin/magento cache:clean full_page
Or ban by URL pattern (adjust it to your URLs; most stores use rewritten product URLs that this example does not match):
varnishadm ban req.url ~ "^/catalog/product"
If that still shows stale stock, check Stores → Configuration → Advanced → System → Full Page Cache: Caching Application must be Varnish Cache, and http_cache_hosts in env.php must point to your Varnish server, or Magento sends no purge requests at all. Export and reload the VCL from the same screen after changes.
One more thing: make sure your product pages aren’t accidentally excluded from ban logic. Magento tags cached pages with X-Magento-Tags headers containing entity IDs. The ban targets those tags. If your Varnish VCL strips those headers or your load balancer isn’t passing them through, bans silently fail.
ACSD-46767 Patch — Fixing Unnecessary Cache Invalidation
Adobe’s ACSD-46767 patch fixes the opposite of a stale page: on affected versions, Adobe Commerce cleared the cached category page every time an order changed a listed product’s quantity, even when the product stayed in stock.
The result was more cache misses, not wrong stock: category pages were rebuilt on the next request, which slows a busy store. Adobe’s expected result after the patch is that the category page loads from the cache when only the quantity changed.
Check if you need it:
According to Adobe, the patch is for Adobe Commerce (all deployment methods) 2.4.4 to 2.4.5-p5, comes with Quality Patches Tool 1.1.46, and the issue is scheduled to be fixed in 2.4.6. Check its status with:
./vendor/bin/magento-patches status
If ACSD-46767 shows as “Not applied” and you are on an affected version, apply it with the Adobe Commerce Quality Patches Tool, on staging first as Adobe advises.
Apply it:
composer update magento/quality-patches
./vendor/bin/magento-patches apply ACSD-46767
./bin/magento cache:clean
After applying, a category page stays in the cache when a listed product’s quantity changes but its stock status does not. That cuts unnecessary rebuilds; on its own it does not fix a page that shows stale stock.
Adobe’s page lists the patch for Adobe Commerce only; on Magento Open Source, check the release notes for your version.
Reducing Varnish TTL for Stock Pages
The default Varnish TTL for Magento pages is often set high — 86400 seconds (24 hours) is common in stock VCL templates. That’s fine for truly static pages like CMS content. It’s a problem for product pages where stock can change multiple times a day.
You don’t need to set TTL to zero. That just turns Varnish into an expensive proxy. Instead, set a shorter TTL specifically for product and category pages.
In your default.vcl, inside the vcl_backend_response function:
sub vcl_backend_response {
if (bereq.url ~ "^/catalog/(product|category)") {
set beresp.ttl = 300s;
}
}
300 seconds (5 minutes) is a reasonable middle ground for most stores. Products that sell fast might need 60–120 seconds. Products with stable stock can stay higher.
Stock-Specific Cache Exclusion and TTL Strategy
Not every page on your store needs the same caching behavior. Product pages with live stock counts are fundamentally different from your About page or blog posts. Treating them the same is where most stock mismatch problems start.

Which Pages Must Always Stay on the Cache Exclusion List
Cart, checkout and My Account pages, covered in the WooCommerce section above, are usually excluded by caching plugins already; check that they are. Two more kinds of URL belong on the list:
- Any URL with a query string you use for stock filtering — something like
?location=warehouse-2or?stock_check=1. These are dynamic by nature. - Stock-sensitive product pages when stock is critically low — if you’re down to 1–5 units, a cached page showing “In Stock” after the item sells is a real problem.
In Magento and Adobe Commerce, avoid cacheable="false" on a block in a product or category layout: one such block makes the whole page uncacheable. Data that must stay fresh per customer belongs in private content (customer sections), which loads after the cached page.
For Varnish setups, exclusions go in your VCL. Minimum rule:
if (req.url ~ "^/(cart|checkout|my-account)") {
return (pass);
}
If a page has stock information that changes very often and a purge on stock change is not set up, put it in the pass list.
Reducing TTL for Stock Pages in Varnish and Nginx (with Config Examples)
Excluding a page entirely from cache isn’t always the right call. A product page with 500 units in stock doesn’t need real-time cache bypassing — but it probably shouldn’t sit in cache for 24 hours either. The fix is a shorter TTL (Time to Live) for stock-relevant pages.
Varnish VCL — per-URL TTL override:
sub vcl_backend_response {
if (bereq.url ~ "^/product/") {
set beresp.ttl = 120s;
}
}
That sets a 2-minute TTL on all product pages. Adjust based on how frequently your stock moves. High-velocity products? Drop it to 30–60 seconds. Slow movers? 5 minutes is fine.
If you want more surgical control — say, a shorter TTL only when stock is below a threshold — you’d need your application to send a custom response header and have Varnish respect it:
In WooCommerce (in a theme’s functions.php or a custom plugin):
add_action( 'template_redirect', function() {
if ( is_product() ) {
$product = wc_get_product( get_queried_object_id() );
if ( $product && $product->managing_stock() && $product->get_stock_quantity() < 10 ) {
header( 'Cache-Control: max-age=30, must-revalidate' );
}
}
});
Then in Varnish VCL, read that header:
sub vcl_backend_response {
if (beresp.http.Cache-Control ~ "max-age=30(,|$)") {
set beresp.ttl = 30s;
}
}
Nginx FastCGI Cache — TTL by location block:
location ~* ^/product/ {
fastcgi_cache_valid 200 2m;
fastcgi_cache_use_stale error timeout;
fastcgi_cache WORDPRESS;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_pass php-fpm;
}
The 2m there is your TTL. WORDPRESS must match the zone name in your fastcgi_cache_path, and php-fpm must be a defined upstream. Change it to 30s for faster-moving stock.
One thing people miss with Nginx FastCGI Cache: the fastcgi_cache_bypass directive. You can use a cookie or request header to skip the cache entirely for specific conditions. Combined with the purge-on-stock-change hook from the Cache Purge Trigger section, you get close to real-time accuracy without disabling caching altogether.
Creating a Bypass Rule for Stock URLs in CDN
CDN edge caches — Cloudflare, Fastly, Akamai, and similar — are where a lot of people get caught out. They configure server-side cache correctly, then forget the CDN layer is sitting in front of everything, serving stale responses from its Edge Cache for hours.
CDN bypass rules follow the same logic as server-side exclusions, but you’re configuring them at the CDN level — usually via page rules, cache rules, or transform rules depending on the platform.
Cloudflare — Cache Rules (new ruleset interface):
Create a rule matching your stock URLs and set the cache status to “Bypass”:
- Expression:
http.request.uri.path contains "/product/"orhttp.request.uri.path contains "/cart/" - Cache setting: Bypass cache
For stock-specific paths only, you can get more precise:
- Match
http.request.uri.query contains "stock_check"→ Bypass
This is especially useful if you’re using AJAX endpoints for stock verification. Any request to /?wc-ajax=get_refreshed_fragments or a custom stock check URL should never be cached at the CDN level. Set those to bypass unconditionally.
Fastly — using surrogate keys / Purge API:
Fastly works better with a Cache Purge Trigger approach. Tag your product pages with a surrogate key (e.g., product-{product_id}) in the response headers, then fire a purge request to the Fastly API whenever stock updates. WooCommerce’s woocommerce_product_set_stock hook is the right place to trigger that purge via a Webhook or a direct API call.
This is more work to set up, but it means your CDN serves cached content right up until a stock change happens — then invalidates immediately. That’s proper Cache Invalidation rather than just reducing TTL and hoping for the best.
One thing to watch with multi-location inventory:
If you’re running stock across multiple warehouses or store locations, the complexity goes up a notch: a customer might see a page cached for another location. Cloudflare does not split its HTML cache by the Vary header, so there you still need a bypass rule; our multi-location plugin’s Pro version also has a query-string fallback that adds the location to the URL.
For single-location WooCommerce stores, CDN bypass rules plus a short TTL on product pages cover most cases without any extra tooling.
Best Practices for Ensuring Real-Time Stock Display
Getting cache configuration right solves the immediate mismatch. But if you stop there, you’re one flash sale or a busy weekend away from the same problem again. The real goal is a setup where stock accuracy is maintained automatically — not something you fix reactively after a customer complaint.
AJAX and Dynamic Stock Display — Implementation Approach
The earlier example uses admin-ajax.php. For a live store, WooCommerce’s own wc-ajax endpoint is the better choice: it skips the WordPress admin code that admin-ajax.php loads, and WooCommerce sends no-cache headers with its responses.
Register the handler on wc_ajax_{action}; it runs for guests and logged-in users alike:
add_action( 'wc_ajax_get_stock_status', 'my_get_stock_status' );
function my_get_stock_status() {
$product_id = isset( $_POST['product_id'] ) ? absint( $_POST['product_id'] ) : 0;
$product = wc_get_product( $product_id );
if ( ! $product || 'publish' !== $product->get_status() ) wp_send_json_error();
wp_send_json_success( [
'stock_quantity' => $product->get_stock_quantity(),
'stock_status' => $product->get_stock_status(),
] );
}
Your JS fires on page load, POSTs to /?wc-ajax=get_stock_status, and updates the displayed quantity in the DOM. The key thing: this request must not be cached. Add Cache-Control: no-store to the response header, or mark the AJAX endpoint URL in your CDN’s Cache Exclusion List.
For Magento / Adobe Commerce, private content (customer sections defined in sections.xml) is meant for per-customer data and is kept in the browser until an action invalidates it, so it is a poor fit for stock. Keep stock in the cached page and rely on tag invalidation, or fetch it with a small AJAX call like the one above.
One practical tip: don’t AJAX-load stock on every product in a category loop. That is one request per product shown. Use it on single product pages and cart interactions where accuracy matters most.
With multi-location inventory, different stock counts per warehouse or store make this matter even more. The free version of our Multi-Location Product & Inventory Management for WooCommerce shows location-specific stock messages and a store location selector; an AJAX product filter by location and stock (the [mulopimfwc_product_filter] shortcode) is part of Pro.
Cache Purge Trigger — Automatically Clear Cache When Stock Updates
A cache purge trigger tells the cache layer to drop the old version when content changes. Without it, you rely on TTL expiry, which can leave stale stock on the frontend for minutes or hours.
In WooCommerce, the hook you want is woocommerce_product_set_stock. This fires every time stock quantity changes — whether from an order, a manual admin update, or an import.
add_action( 'woocommerce_product_set_stock', 'my_purge_product_cache' );
function my_purge_product_cache( $product ) {
$product_id = $product->get_id();
$product_url = get_permalink( $product_id );
// Example: purge via LiteSpeed Cache
do_action( 'litespeed_purge_post', $product_id );
// Example: send a purge request to Varnish
// Send it to the Varnish host directly; your server's IP must be in Varnish's purge ACL.
wp_remote_request( $product_url, [ 'method' => 'PURGE', 'blocking' => false, 'timeout' => 2 ] );
}
Adjust the purge call to match your stack. Varnish accepts a PURGE HTTP method. Nginx FastCGI Cache uses fastcgi_cache_purge (requires the nginx cache purge module). LiteSpeed Cache has its own API class. For CDN-level edge cache, most providers (Cloudflare, Fastly, Bunny.net) offer a REST API endpoint for URL-based purges — fire a wp_remote_request() to that endpoint from the same hook.
For woocommerce_variation_set_stock, do the same for variable products.
In Magento, cache invalidation is built into the product save process — stock changes trigger a cache invalidation event automatically for the affected product URLs. The gap usually comes from custom stock integrations that write directly to the database and skip the product save flow. In those cases, you need to register the product IDs in Magento\Framework\Indexer\CacheContext and dispatch the clean_cache_by_tags event so the cached pages for those products are cleared.
Keep TTL (Time to Live) short on product pages — a few minutes is reasonable for most stores. High-volume flash sale environments may need it down to 60–90 seconds, or AJAX stock loading combined with a short TTL.
Ensuring Stock Sync with Webhooks or Cron Jobs
If your stock source of truth is external — an ERP, a POS system, a warehouse management system — the frontend mismatch often isn’t a cache problem at all. The stock in WooCommerce or Magento is simply out of date. Cache just makes it worse by serving that outdated number longer.
Two patterns handle this:
Webhooks push stock changes to your store the moment they happen in the external system. Your WMS or ERP sends an HTTP POST to a custom endpoint on your site; your endpoint receives it, updates the WooCommerce product stock, and optionally triggers a cache purge. This is near real-time. The downside: your store needs to be reachable from the external system, and you need to validate the incoming payload (signature check, not just blind trust).
WooCommerce has its own outbound webhook system. Go to WooCommerce → Settings → Advanced → Webhooks, create a webhook on the topic that matches the change, for example order.created or product.updated, and test that it fires for stock changes from orders, not only for edits in the admin. For inbound syncs (external → WooCommerce), you’ll need a custom REST API endpoint or a dedicated sync plugin.
Cron Jobs poll for changes on a schedule. Less immediate than webhooks, but simpler to implement and more resilient to network failures. In WordPress, wp-cron runs on page load — not ideal for reliable sync timing. Use a real server cron instead:
*/5 * * * * php /var/www/html/wp-cron.php # also add define( 'DISABLE_WP_CRON', true ); to wp-config.php
That fires every 5 minutes. Your custom cron callback fetches stock from the external API, compares against current WooCommerce stock, and updates where there’s a difference. Register it with:
add_filter( 'cron_schedules', function( $schedules ) {
$schedules['every_five_minutes'] = array( 'interval' => 300, 'display' => 'Every 5 minutes' );
return $schedules;
} );
add_action( 'my_stock_sync_cron', 'my_run_stock_sync' );
if ( ! wp_next_scheduled( 'my_stock_sync_cron' ) ) {
wp_schedule_event( time(), 'every_five_minutes', 'my_stock_sync_cron' );
}
For multi-location setups, where each warehouse or store location has its own stock level, the sync work multiplies: one number per product per location. The Pro version of our Multi-Location Product & Inventory Management for WooCommerce has a REST inventory API and a webhook endpoint, secured with an API key or webhook secret, so a WMS or ERP can push stock for a specific location. The free version handles per-location inventory inside WooCommerce.
In Magento, stock that arrives through a custom integration is where invalidation most often breaks, as noted above.
Cache Mismatch in WooCommerce Multi-Location Inventory Is a Different Problem
In a multi-location store there is one stock number per location, each cached separately, each with its own TTL and each visible to the customers who chose that location.
The root mechanics are the same: Full-Page Cache, Object Cache, Transients. But the scope of what “correct” means has multiplied. A customer in Location A seeing stale stock is a different bug than a customer in Location B seeing the same thing, even if they’re on the same product page URL.
Each Location Has Separate Stock — How to Tell Which Location’s Cache Is Stale
The first thing to understand is that most caching systems key cached responses by URL. If your multi-location setup uses a query parameter — say ?location=3 or a cookie to segment stock — your cache layer may or may not respect that. Many don’t, by default.
Here’s what stale location stock actually looks like in practice:
- A customer has Location B selected. The product page loads and shows 12 units. Actual stock at Location B is 0.
- Admin confirms Location B = 0, Location A = 12. The cache served Location A’s stock to a Location B customer — or served an old Location B value from before the last sale.
To figure out which location’s data is stale, test systematically. Clear your browser cookies, select each location one at a time, and record the stock shown. Then compare against the admin panel for that specific location. The location with the mismatch is the one with a stale cache entry.
If your caching layer is Varnish or Nginx FastCGI Cache, check whether it’s varying the cache by cookie or by query string. If it’s not, every customer gets the same cached page regardless of their selected location — which means you’re always serving whichever location happened to be active when the cache was first primed.
The fix at the cache layer: add a Vary header for your location cookie, or exclude location-switching URLs from the full-page cache entirely. In Nginx:
fastcgi_cache_bypass $cookie_mulopimfwc_store_location;
fastcgi_no_cache $cookie_mulopimfwc_store_location;
That tells Nginx not to serve or store a cached response when a location cookie is present. It’s blunt but it works. A more surgical approach is creating separate cache keys per location value — some setups support this natively, others need custom Varnish VCL.
On the WordPress/WooCommerce side, also check how your multi-location tool stores each location’s stock. Our plugin keeps it in product meta, so it changes as soon as an order or edit saves; if your tool caches location stock in transients, clear them with delete_transient() when stock changes instead of waiting for them to expire.
Plugincy Multi-Location Inventory Plugin — Built-In Clear Cache Tool (Free)
If you’re running Multi-Location Product & Inventory Management for WooCommerce by Plugincy, our own plugin, its cached data can be cleared from the admin.
The free version has a Clear Cache button under Location Manage > Settings > Advanced. It clears the plugin’s own cached records, such as dashboard totals, and the plugin also clears that cache automatically when products or variations are updated.

Location-wise pricing is a Pro feature.
Use the button after a bulk stock import or a bulk location assignment, then check one product per location on the frontend.
It does not clear your page cache, object cache or CDN; those still need the purge steps above.
Stock Display Formats and Location-Aware Cache Handling (Pro)
Even with cache properly invalidated, there’s a timing gap. A sale happens, the cache gets stale for seconds or minutes, and a second customer sees the wrong number. For high-traffic stores or products with limited stock across locations, that gap matters.
The Pro version adds more stock display formats: besides the exact stock count (free), it can show only availability (In Stock/Out of Stock), stock levels (High/Medium/Low) or hide stock information. A label such as High/Medium/Low goes out of date far less often than an exact count.
For page caches, the free version already sends a Vary: Cookie header on cacheable guest pages, because the page depends on the selected-location cookie, so caches that honour Vary keep a separate copy per location. The Pro version adds direct cache rules for LiteSpeed Cache, WP Rocket, W3 Total Cache and WP Super Cache.
Some caches and CDNs ignore Vary. For those, the Pro version has an optional query-string fallback, turned on with the mulopimfwc_cache_querystring_fallback_enabled filter, that redirects to a URL with the location added (?mulopim_loc=), so each location gets its own cache key.
Neither feature loads the stock figure separately by AJAX. If you need an exact count that is always current, combine them with a purge on stock change or the AJAX pattern shown earlier.
If you’re running a single-warehouse store, this level of detail isn’t necessary. With several locations and customers switching between them, you need both: a cache that keeps a copy per location, and a purge or short TTL when stock changes.
Quick Reference — Find the Fix Based on the Symptom
Match what you see to one of the symptoms below; each one points to the cache layer most likely holding the old stock and the first thing to change. The table at the end of this section sums them up.
Stock Shows Correctly in Admin but Frontend Is Stale After a Purchase
Most likely cause: Full-Page Cache (FPC) — Varnish, Nginx FastCGI Cache, or LiteSpeed Cache — served a cached copy of the product page before the cache invalidated.
Fix: Add the product page to your Cache Purge Trigger list so it clears whenever WooCommerce fires woocommerce_reduce_order_stock. If you’re on LiteSpeed Cache, use LiteSpeed Cache → Toolbox → Purge to purge the URL, and check its WooCommerce settings for purging products on stock changes. On Varnish, check that your BAN or PURGE requests are reaching the correct host header.

Stock Looks Wrong but Refreshes After Hard Reload (Ctrl+Shift+R)
Most likely cause: Browser Cache. The user’s browser is serving a locally cached page — nothing to do with your server.
Fix: Set proper Cache-Control headers on stock-related pages. Specifically, stock display elements should carry no-store or a short max-age. This is usually a header configuration at the Nginx or Apache level, not inside WooCommerce itself.
Stock Is Wrong for Some Visitors but Correct for Others
Most likely cause: CDN Edge Cache or a geographically distributed cache layer (Cloudflare, Fastly, etc.) is serving different cached responses to different regions or PoPs (Points of Presence).
Fix: Exclude your product URLs from edge caching, using the CDN bypass rules above, or set the TTL on product pages to something very short, under 60 seconds if your stock moves fast. Loading stock by AJAX, covered earlier, also works here.
Stock Resets to an Old Number Every Few Hours
Most likely cause: WooCommerce Transient Cache or Object Cache (Redis, Memcached) holding stale product data, such as an old product object or variation list.
Fix: Check your Object Cache configuration. If you’re on Redis, use the redis-cli --scan check from Step 4 to see what’s cached and confirm the TTL values. You can force clear a product’s WooCommerce transients with wc_delete_product_transients( $product_id ). Add that call to the stock-change hook so it runs automatically.
Magento / Adobe Commerce Frontend Shows Old Stock After You Updated It in Admin
Most likely cause: Magento’s Full-Page Cache hasn’t invalidated for that product. With Varnish, this usually means the purge request did not reach Varnish.
Fix: Go to System → Tools → Cache Management and flush the FPC manually to confirm. If that corrects it, the real fix is ensuring your Varnish BAN configuration is working correctly on stock saves. ACSD-46767 will not help here: it stops extra category-cache clearing on Adobe Commerce 2.4.4 to 2.4.5-p5, not missing invalidation.
Stock Is Wrong Only on Category / Collection Pages, Not on the Product Page Itself
Most likely cause: Category pages are cached at a different TTL than product pages, or the stock badge on category pages is rendered server-side during the cache build — not pulled dynamically.
Fix: Either reduce the TTL on category/archive pages specifically, or switch the stock badge to an AJAX-loaded component. The HTML of the category page should not contain a hardcoded stock number — that value will go stale the moment your cache is warmer than your stock movements. On WooCommerce, hooking into woocommerce_after_shop_loop_item with an AJAX call is the right approach.
Stock Is Wrong Only for Logged-Out Users
Most likely cause: Your FPC is only active for guests (most setups exclude logged-in users from full-page caching, which is correct). The cached page was built with old stock data.
Fix: This confirms FPC is the culprit. Your logged-in users bypass FPC and hit live data — guests don’t. The fix is either a shorter TTL on product pages, a proper cache purge on stock change, or loading stock values via AJAX so the cached HTML shell doesn’t carry the number at all.
Multi-Location Setup — Customer Sees Wrong Stock for Their Selected Location
This one’s different from standard cache problems. The page might be correctly cached for one location’s stock but served to a customer who selected a different location. Standard cache layers have no concept of “which location did this customer pick.”
You need either per-location cache variations or dynamic stock display via AJAX that fires after the customer’s location selection is read from their cookie or session.
If you’re building this yourself, the key is: never render the per-location stock count in the cached HTML. Always fetch it client-side after reading the customer’s saved location from their session or a cookie.
Quick Symptom → Fix Map
| Symptom | Likely Layer | First Action |
|---|---|---|
| Stale after purchase, clears after cache flush | FPC (Varnish/LiteSpeed/Nginx) | Add purge trigger on stock change |
| Fixed by hard reload only | Browser Cache | Set Cache-Control: no-store on product pages |
| Different stock for different visitors | CDN Edge Cache | Bypass edge cache for /product/* or use AJAX |
| Resets to old number every few hours | Transient / Object Cache (Redis/Memcached) | Reduce TTL or clear on stock update |
| Magento admin correct, frontend wrong | Magento FPC | Flush cache, check the Varnish purge setup |
| Wrong on category pages, right on product page | Archive page cache TTL | Lower TTL or move stock display to AJAX |
| Wrong for guests, right for logged-in users | FPC (guest-only caching) | Shorter TTL + purge triggers, or AJAX stock display |
| Wrong per location in multi-location store | No location-aware cache layer | AJAX stock fetch post-location-selection |
Warnings — These Mistakes Will Bring the Problem Back
Fixing a stock cache mismatch is one thing. Keeping it fixed is another. These are the mistakes that cause the problem to quietly return.
Setting a Single TTL for Everything
This is probably the most common one. You fix the immediate issue, then configure a blanket TTL — say, 24 hours — across all cached pages. Stock pages are now cached for 24 hours just like your About page.
Short TTLs solve stale stock. Long TTLs help performance. You can’t have both with one setting. The fix is to use different TTLs by URL pattern or content type. Product pages need a TTL measured in minutes (or zero TTL with AJAX stock fetch). Static pages can stay cached for hours or days. If your caching layer doesn’t support per-path TTL rules, that’s the upgrade you actually need — not just a cache purge.
Excluding Stock from Cache Purge Triggers
A cache purge trigger fires when something changes and tells the cache to drop the stored version. Most setups configure these triggers for things like new posts or theme changes. Stock updates rarely make it onto that list by default.
If your Varnish, Nginx FastCGI Cache, or CDN isn’t wired to purge on stock changes, the old page stays cached no matter what happens in the database. Check that woocommerce_product_set_stock or your WMS webhook actually invalidates the right cached URLs. If it doesn’t, you’re purging manually every time — which means you will forget, and the mismatch will come back.
Forgetting Browser Cache and Edge Cache After Fixing Server-Side Cache
You flush Redis. You purge Varnish. The server is clean. But a customer opened the product page an hour ago and their browser still holds the old HTML, or your CDN’s edge node hasn’t picked up the new version yet.
Server-side cache invalidation is not the whole job. Browser cache is controlled by Cache-Control and Expires headers. Edge cache on your CDN has its own TTL that may not honor your origin’s purge. After a fix, verify with an incognito window on a network you haven’t visited from before — or use a VPN to hit a different CDN edge node. If the stale stock still appears, the problem has moved downstream, not disappeared.
Re-Enabling a Cache Layer You Disabled During Testing
During diagnosis, disabling LiteSpeed Cache or bypassing Varnish helps you confirm where the stale data lives. That’s correct. What breaks things is forgetting to re-apply your exclusion rules when you re-enable it.
You turn caching back on, traffic returns to normal, and the exclusions you carefully configured are now gone — or never applied to the re-enabled plugin because you toggled it off and back on without checking. Always verify your Cache Exclusion List is intact after any caching plugin update or toggle. Recheck the list after each caching plugin update.
Using Object Cache Without Expiring WooCommerce Transients on Stock Changes
Redis and Memcached are fast. They’re also persistent across page loads, which is exactly why stale Transient Cache data from WooCommerce can sit there long after stock has changed. Cached product objects and variation lists doesn’t always expire when it should — especially if you’re using a persistent object cache backend that doesn’t respect WordPress’s built-in transient cleanup.
The fix is to clear the product’s cached data when stock changes: call wc_delete_product_transients() and clean_post_cache() from the woocommerce_product_set_stock hook, as shown in the WooCommerce section.
Assuming the Fix Works for Multi-Location Stock Too
Standard cache fixes work when your stock lives in a single WooCommerce product record. When customers see location-specific stock — warehouse A has 3 units, warehouse B has 0 — the data source is different, and so is the invalidation requirement.
A cache exclusion rule that works for global stock won’t automatically cover per-location stock displays. If you’re running a multi-location setup (whether through a dedicated plugin or custom tables), each location’s stock data needs its own invalidation path, because the standard WooCommerce purge hooks may not reach custom location data. Trace the data source and make sure your purge trigger reaches it.
Not Monitoring After the Fix
A cache mismatch can look solved and then silently return after a plugin update, a hosting change, or a CDN configuration refresh. Set up at least a basic check: a cron job or an uptime monitor that compares the stock quantity visible on a product page against the admin value for a few tracked products. If those diverge by more than a few minutes, something has broken again.
Frequently Asked Questions (FAQ)
Store owners chasing stale stock usually ask why a cache clear only helps for a while, how to find the layer, and what to check for Magento, the REST API, LiteSpeed, browser cache, webhooks and multi-location stores.
Why does clearing the cache fix the stock display, but the problem keeps coming back?
A manual clear removes the stale copy once — but if your TTL is set too high, or you have no cache purge trigger tied to stock changes, the stale data just accumulates again. You need either a short TTL on product pages (60–300 seconds is reasonable for high-turnover stock) or an automatic purge that fires whenever WooCommerce updates stock.
My CDN is showing the wrong stock. Does that mean my server cache is fine?
Not necessarily — it means the bad response made it out to the edge. CDNs like Cloudflare cache what your origin server sends them. If Varnish or Nginx FastCGI Cache served a stale HTML page, that stale page is what gets stored at the edge. You may need to fix both layers: exclude product pages from Edge Cache, or set up a Cache Purge Trigger at the CDN level so it pulls a fresh copy when stock changes.
How do I know which cache layer is causing the mismatch?
Load the product page in a browser you’ve never used before (or a private window with DevTools open). Check the response headers — look for X-Cache: HIT, CF-Cache-Status: HIT, Age: 3842, or similar. A high Age value means a CDN or reverse proxy is serving a cached copy. If headers look clean but stock is still wrong, open the page while logged into WordPress — if the logged-in view shows correct stock, the issue is Full-Page Cache or Varnish, not the database. If both views are wrong, suspect Object Cache (Redis or Memcached) or a WooCommerce Transient Cache issue.
Can I just exclude all product pages from cache to solve this permanently?
You can, but you probably shouldn’t. Excluding every product page from FPC costs a lot of speed. A better approach: keep the page cached and load only the stock figure through a separate AJAX request, as in the earlier example. Full page exclusion is a last resort, not a strategy.
In Magento, I patched ACSD-46767 but the stock is still wrong. What now?
ACSD-46767 fixes one specific category-page caching bug. If your mismatch is on a product detail page, or it’s coming from a different cache layer entirely, that patch won’t help. Check your Varnish purge setup (Magento section above). The patch is a narrow fix — it doesn’t solve every stock cache problem in Adobe Commerce.
WooCommerce shows the right stock in admin but wrong stock in a REST API response. Is that also cache?
It can be. WooCommerce REST responses can be served through Object Cache or even an Nginx FastCGI Cache layer if your server isn’t configured to exclude API routes. Check that /wp-json/wc/v3/products/* is in your Cache Exclusion List. Also verify that your Redis or Memcached instance isn’t holding a stale product object — flush it and test the API response again. If the API returns correct stock after a flush, you’ve found your layer.
How do multi-location setups make this worse?
In a standard single-location store, stock is one value per product. With Multi-Location Inventory, each location holds its own stock count, and the cached page might show the stock of the wrong location entirely, not just an outdated number for the right one. That is why per-location stock needs either a cache that keeps one copy per location or a stock figure loaded by AJAX. Our own Multi-Location Product & Inventory Management for WooCommerce keeps the selected location in a cookie and sends a Vary: Cookie header in its free version; Pro adds cache-plugin integrations, a location product filter and extra stock display formats.
LiteSpeed Cache is installed. What settings do I check for stock issues?
Go to LiteSpeed Cache → Cache → Excludes and add your product page URLs or URL patterns to the Do Not Cache URIs list if needed. ESI (Edge Side Includes) can serve parts of a page fresh, but the stock text has to be output as an ESI block, which usually means custom work. Also check Object Cache settings: LiteSpeed Cache can run the object cache too, and purging it separately from the page cache is sometimes necessary.
My developer says the stock is correct in the database. Why is it still wrong on the frontend?
The database is the source of truth, but it’s not always what the frontend reads. Between the database and the browser, you have WooCommerce Transient Cache, Object Cache (Redis/Memcached), Full-Page Cache, and potentially a CDN or Browser Cache layer on top. Correct data in the database means nothing if an intermediate layer is serving a cached response before the query even runs. Work outward from the database: flush each layer in sequence and test after each one until the correct value appears.
Is there a way to get real-time stock display without disabling cache entirely?
Yes. The standard approach is Cache Bypass for the stock quantity only. You keep the product page cached, then use a small AJAX call to fetch current stock separately — that request bypasses the page cache because it hits a non-cached endpoint. WooCommerce does some of this natively (add-to-cart AJAX validation, for instance), but the displayed stock number itself often isn’t updated unless you add a small script like the one above. That way your Time to First Byte stays fast, cache hit rates stay high, and customers still see accurate stock.
Does Browser Cache cause this problem too?
Occasionally. It is less often the culprit than server-side layers, because WordPress pages are usually sent without a long browser cache lifetime. But if a customer loaded a product page, left, and came back within the browser cache window, they might see stale stock. Setting Cache-Control: no-store or a short max-age on product pages in your server config addresses this — though it’s rarely the primary cause of the mismatch reported in admin vs frontend situations. Focus on server-side and CDN layers first.
How do I test whether a Webhook or Cron Job is actually triggering a cache purge on stock change?
For Cron Jobs: install WP Crontrol (free on WordPress.org) and manually run the relevant WooCommerce cron event, then check whether cached stock updates. For Webhooks: use a tool like RequestBin or Webhook.site to log the outgoing payload and confirm it’s firing with the correct stock value. On the cache side, check your caching plugin’s log (LiteSpeed Cache and similar plugins keep purge logs) to verify a purge event was recorded at the right time. If the webhook fires but the cache doesn’t purge, the issue is in how your cache plugin responds to that event — not in the webhook itself.
Conclusion — Identify the Right Layer and Fix It Once for Good
Cache mismatches aren’t random. In most cases one layer is holding old stock data longer than it should, and once you know which layer, the fix is usually clear.
Check the response headers before changing anything.
If your admin shows the correct stock and your frontend doesn’t, you’re not looking at a WooCommerce bug or a database problem. You’re looking at a cached response somewhere between your database and the browser. It’s either Full-Page Cache (FPC), Object Cache, a CDN edge node, Varnish, Nginx FastCGI Cache, LiteSpeed Cache, a transient that’s still within its TTL, or — less often but it happens — the browser’s own cache.
Fix it at the right layer, not just the nearest one.
A lot of stores “fix” this by adding a blanket purge-all rule on every page load, or by disabling caching entirely on product pages. That works, but you’ve just traded one problem for another — slower pages and higher server load. The right approach is a targeted Cache Exclusion List for stock-sensitive pages, a tight TTL on anything inventory-related, and a Cache Purge Trigger that fires when stock actually changes. That means hooking into woocommerce_product_set_stock or using your platform’s stock update event to invalidate only what changed.
The CDN layer catches a lot of people off guard. You can purge everything at the server level and still serve stale stock to users hitting an edge node that hasn’t been told to revalidate. Build your Cache Purge Trigger to reach the CDN too — most major providers expose an API for this.
On the AJAX side: if your add-to-cart and stock display are already handled via AJAX calls, the FPC layer won’t affect those responses — but your Object Cache (Redis or Memcached) still can. Make sure those calls either bypass the object cache for stock quantities or that the relevant keys are flushed on stock update.
Multi-location setups add a layer of complexity. When a customer selects a location and sees stock from Warehouse B, but your FPC cached the page when Warehouse A was selected, you get a mismatch that looks like a standard cache problem but has a different root. The fix isn’t just purging: location-specific stock has to be either loaded by AJAX or cached per selected location.
Stock Sync between systems — whether via Webhook, Cron Job, or a REST API — only solves half the problem if the cache layer doesn’t know a sync just happened. Make sure your sync process ends with a cache purge step, not just a database write.
Three things to lock in before you close this out:
- Confirm the layer — use an incognito tab, a curl request with cache-bypass headers, and your caching plugin’s or server’s debug tools. Don’t assume.
- Set the right TTL — stock pages should have a short TTL (under 5 minutes is reasonable for most stores; real-time display needs AJAX or a full Cache Bypass).
- Automate the purge — manual cache clears are a temporary patch. A purge tied to stock change events keeps the page current automatically.