On this page
What this issue is
WooCommerce loads a script called cart-fragments.js. It asks your server for the current mini-cart contents through an Ajax request: /?wc-ajax=get_refreshed_fragments. Ajax means the page asks the server for data in the background after it loads.
Your page can come from a full-page cache, which is fast. This Ajax request cannot be cached in the same way, because every visitor has their own cart. So each page view still runs WordPress, WooCommerce and database queries. Add many visitors and the server queue grows.
Why it costs you leads or sales
The problem shows up when traffic is highest: a campaign launch, an email send or a sale. Pages that were fast in testing turn slow, product pages take longer to respond and carts or checkouts can time out. Paid visitors who wait leave, and you have already paid for the click.
- Ad clickVisitor lands on a product page
- Cached HTMLServed fast from cache
- Cart fragments callwc-ajax request hits PHP and database
- Add to cartSlow or timing out
- CheckoutVisitor has left
The cached HTML is quick, but the cart fragments call reaches PHP and the database on each view. Under load this queue slows everything behind it.
Example: response time of the fragments request on a shared server as concurrent visitors rise. Your numbers will differ.
How to check if your site has it
Open the Network tab
In Chrome, open your product page, press F12, choose Network and reload. Filter by
wc-ajax.Look for get_refreshed_fragments
If you see
?wc-ajax=get_refreshed_fragmentson pages with no cart, the script is running everywhere.Read the Waiting (TTFB) time
Click the request and open Timing. A long Waiting for server response time means PHP and the database are busy.
Check under loadWordPress
Repeat during a busy period, or ask your host for slow query and PHP worker logs. Query Monitor, a free WordPress plugin, lists slow queries.
How to fix it
The main fix is to stop loading cart fragments on pages where a live mini-cart is not needed, such as landing pages, blog posts and category pages. Then check that page caching works and the server can cope.
Use a performance plugin option
Several optimisation plugins have a setting to disable WooCommerce cart fragments. Look in the plugin's WooCommerce or Heartbeat/Bloat settings. Names vary by plugin.
Or add a code snippet
Add the snippet below to a child theme's functions.php or a snippets plugin. Test the mini-cart afterwards.
Dequeue the script on selected pages
Use the PHP snippet below, and keep the script on the cart and checkout pages where it is needed.
Add caching for the rest
Make sure the full-page cache excludes only cart, checkout and account pages.
Not applicable
Shopify does not use WooCommerce cart fragments. If you see slow cart calls, check your theme's cart drawer apps instead.
add_action( 'wp_enqueue_scripts', function () {
if ( function_exists( 'is_cart' ) && ( is_cart() || is_checkout() ) ) {
return;
}
wp_dequeue_script( 'wc-cart-fragments' );
}, 11 );Enable full-page caching
Cache product, category and landing pages. Exclude cart, checkout and My Account only.
Add an object cacheWordPress
Ask your host about Redis or Memcached. It cuts repeated database queries.
Clean the databaseWordPress
Remove expired transients and old sessions. WooCommerce stores sessions in the
wp_woocommerce_sessionstable, which can grow large.Check PHP workers and hosting
If all PHP workers are busy, requests queue. Ask your host for more workers or a bigger plan.
How to confirm it's fixed
- The Network tab no longer shows
get_refreshed_fragmentson landing, blog and category pages - Mini-cart and cart count still update correctly after add to cart
- Cart and checkout pages still work from start to finish
- Page response time stays low during a busy period
- Host logs show fewer slow queries and no PHP worker limit warnings
Before
- Cart fragments request on every page
- Each view runs PHP and database queries
- Slows down when ad traffic arrives
After
- Script loads only where needed
- Most views served from cache
- Server keeps headroom during peaks
How to prevent it happening again
- Load test or watch response times before big campaigns
- Re-check the Network tab after theme, plugin or WooCommerce updates
- Keep cart, checkout and account pages as the only cache exclusions
- Review slow queries monthly with your host or Query Monitor
- Remove plugins that add their own Ajax calls on every page
How FunnelGuard handles this
FunnelGuard detects this only partly. It checks TTFB (time to first byte) and step duration while its robot visitor runs your journeys on a schedule. If product pages, add to cart or checkout become slow, you get an alert with a screenshot and a likely cause, after a re-check from a second region.
Questions people ask
What are WooCommerce cart fragments?
Cart fragments are a WooCommerce script that updates the mini-cart through an Ajax request called ?wc-ajax=get_refreshed_fragments. It runs on page loads so the cart count stays current. The request bypasses page caching and uses PHP and the database.
Why is my WooCommerce site slow when traffic spikes?
A common cause is uncached requests such as cart fragments, which run PHP and database queries for each visitor. When many people arrive at once, PHP workers fill up and requests queue. Check caching, object cache, slow queries and your host's worker limits.
Is it safe to disable WooCommerce cart fragments?
Yes, on pages that do not show a live cart, such as landing pages and blog posts. Keep it on cart and checkout, and test any header mini-cart. If the cart count goes stale, restore the script there.
How do I find the get_refreshed_fragments request?
Open your page, press F12, go to Network, reload and filter by wc-ajax. Click the request and open Timing to see how long the server took to respond. Long waiting times point to a busy server.
Does a caching plugin fix cart fragments?
Not by itself. A cache serves the page HTML, but the fragments request is per visitor and still reaches the server. You need to disable the script where it is not needed and keep caching for the pages themselves.
Does FunnelGuard detect slow cart fragments?
Only partly. FunnelGuard measures TTFB and step duration on your journeys and alerts you when they slow down. It does not tell you that cart fragments are the cause or run load tests, so you confirm that by hand.
Will removing cart fragments break my cart?
It should not break the cart or checkout if you keep the script on those pages. It only affects live updates of the mini-cart elsewhere. Test add to cart and checkout after the change.
Related issues
- PRF-066admin-ajax.php requests slow down every WordPress pageFix guide
- PRF-064Slow checkout API (cart, shipping calc) responsesFix guide
- PRF-053Full-page cache disabled or bypassed (WordPress cache plugin off)Fix guide
- PRF-051TTFB spikes at certain times (cron, backups, traffic peaks)Fix guide
- PRF-050TTFB over 800 msFix guide
- PRF-061Origin server returns 5xx intermittentlyFix guide