Skip to content
FunnelGuard

Fix guide by FunnelsGuard

WooCommerce cart fragments slowing your site: how to fix it

PRF-065Medium impactPartlyBy FunnelGuardPublished Updated
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.

How a cached page still loads the database
  1. Ad clickVisitor lands on a product page
  2. Cached HTMLServed fast from cache
  3. Cart fragments callwc-ajax request hits PHP and database
  4. Add to cartSlow or timing out
  5. 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.

Response time as visitors growExample numbers
Response time as visitors grow (example)10 visitors: 250 ms; 50 visitors: 600 ms; 100 visitors: 1,500 ms; 200 visitors: 4,000 ms01,5333,0672506001,5004,00010 visitors50 visitors100 visitors200 visitorsms

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

Confirm the request is slow
  1. Open the Network tab

    In Chrome, open your product page, press F12, choose Network and reload. Filter by wc-ajax.

  2. Look for get_refreshed_fragments

    If you see ?wc-ajax=get_refreshed_fragments on pages with no cart, the script is running everywhere.

  3. 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.

  4. 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.

Disable cart fragments where not needed
  1. 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.

  2. 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 cart fragments outside cart and checkoutphp
add_action( 'wp_enqueue_scripts', function () {
    if ( function_exists( 'is_cart' ) && ( is_cart() || is_checkout() ) ) {
        return;
    }
    wp_dequeue_script( 'wc-cart-fragments' );
}, 11 );
Then reduce the load behind it
  1. Enable full-page caching

    Cache product, category and landing pages. Exclude cart, checkout and My Account only.

  2. Add an object cacheWordPress

    Ask your host about Redis or Memcached. It cuts repeated database queries.

  3. Clean the databaseWordPress

    Remove expired transients and old sessions. WooCommerce stores sessions in the wp_woocommerce_sessions table, which can grow large.

  4. 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

Confirm after the change
  • The Network tab no longer shows get_refreshed_fragments on 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 and after

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

Habits that keep it fixed
  • 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.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: TTFB/duration only.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.