If you’ve ever run a WooCommerce store through a speed test, you’ve probably seen a request to a URL ending in ?wc-ajax=get_refreshed_fragments. On many stores, it’s one of the slowest requests on the page, sometimes taking a second or more, and it appears on every single page view, including blog posts and the contact page. WooCommerce cart fragments are behind that request.
This is the cart fragments feature. It’s there for a good reason, but on many stores it costs far more than it’s worth. Understanding what it does lets you decide how to handle it on your own store.
What cart fragments do
Most WooCommerce themes show a cart icon in the header with the number of items, and sometimes a dropdown mini cart showing the products. That information is different for every visitor.
The problem is page caching. When pages are cached, every visitor receives the same HTML. If the cached page shows “Cart (0)”, a visitor with three items in their cart would see the wrong number.
Cart fragments solve this. After the cached page loads, a small piece of JavaScript makes an AJAX request to WooCommerce, which returns the current cart HTML for that visitor. The script then replaces the cart icon and mini cart with the correct, personalised versions. These replaceable pieces of HTML are the “fragments”.
The fragments are also stored in the browser’s session storage, so on later pages the script can use the stored version instead of asking the server again, at least in theory.
Why it causes performance problems
Several things make cart fragments expensive.
It bypasses the page cache. The AJAX request goes straight to PHP, loads WordPress and WooCommerce fully and queries the database. That’s exactly the work page caching was meant to avoid.
It runs for everyone. Even visitors with empty carts, even bots, even people reading a blog post who’ll never buy anything.
It loads WooCommerce in full. Every plugin that hooks into WooCommerce or WordPress initialisation runs during the request. On a store with many plugins, that can take hundreds of milliseconds or more.
It runs again under certain conditions. Session storage gets cleared, the cart hash changes or the page is opened in a new tab, and the request runs again.
On a busy store, cart fragments can account for a large share of total PHP load. During a traffic spike, they can be the thing that takes the server down, because every cached page view still generates an uncached request.
Changes in recent WooCommerce versions
WooCommerce has changed how cart fragments load. Since version 7.8, the cart fragments script is no longer loaded on every page by default. It’s only enqueued when the theme’s mini cart widget or similar features need it. Block-based themes using the Mini-Cart block don’t rely on the legacy cart fragments script at all; the block fetches cart data through the Store API in its own way.
But many classic themes and page builders still load cart fragments on every page, either deliberately or because they enqueue the script themselves. So check your own store rather than assuming.
Check whether your store uses it
Open any page in a private browser window, with developer tools open on the Network tab. Look for a request containing wc-ajax=get_refreshed_fragments. Note how long it takes and whether it appears on every page.
Then add a product to the cart and browse a few pages. Does the request run again? Does the cart count update correctly?
Also check the pages where it appears. If it fires on blog posts, the about page and the contact page, that’s usually unnecessary.
Option 1: Load it only where it’s needed
The most common and safest approach is to disable cart fragments on pages where the cart display doesn’t matter, typically non-WooCommerce pages, while keeping it on shop, product, cart and checkout pages.
The trade-off is that the header cart count on blog pages may show a cached value. For many stores, that’s acceptable, especially if blog visitors rarely have items in their carts.
Option 2: Load it only when the cart has items
A smarter approach checks whether the visitor has anything in their cart. WooCommerce sets a cookie called woocommerce_items_in_cart when the cart contains items. If the cookie isn’t present, there’s nothing personalised to show, and the cached “empty cart” state is correct.
Some performance plugins implement this: they skip the fragments request when the cookie is absent. That removes the request for the vast majority of visitors, including all bots and first-time visitors, while keeping the cart accurate for people who have added products.
Option 3: Use the Mini-Cart block
If you’re using a block theme or can switch your header to blocks, the WooCommerce Mini-Cart block is designed to work without the legacy cart fragments system. It’s lighter and more cache-friendly. For stores planning a redesign, moving to a block-based header is a good long-term fix.
Option 4: Don’t show a live cart count at all
Some stores simply remove the cart count from the header, showing a cart icon that links to the cart page. Customers who want to see their cart click it. It’s a design decision with a small usability cost, but it removes the problem entirely. Some stores show a live count only on product and shop pages.
Option 5: Cache fragments at the edge
Advanced setups use edge-side includes or similar techniques to cache most of the page and fetch only the cart portion separately. LiteSpeed’s ESI and Varnish can do this. It’s effective but more complex, and best left to developers familiar with the caching layer.
What not to do
Don’t simply disable cart fragments everywhere without testing. If your theme relies on them for the add-to-cart flow, removing them can break things:
- The cart count doesn’t update after adding to cart
- AJAX add-to-cart buttons on shop pages stop showing confirmation
- The mini cart dropdown shows stale contents
Always test the full journey after changing fragments: browse, add to cart from the shop page, add to cart from a product page, view the cart, change quantities, remove items and check out.
The admin-ajax and wc-ajax distinction
Older WooCommerce versions sent cart fragments through admin-ajax.php. Modern versions use the lighter wc-ajax endpoint, which skips some admin initialisation. If you see fragments going through admin-ajax.php, your WooCommerce version or theme may be very out of date, which is worth investigating for other reasons too.
Measure the impact
Before and after any change, measure:
- Time for the fragments request on a typical page
- Number of uncached PHP requests per page view, from server logs
- Server load during busy periods
- Lab metrics like Total Blocking Time and real user metrics like INP
On stores I’ve worked on, limiting cart fragments has reduced uncached PHP requests by more than half and noticeably improved responsiveness during sales.
Cart fragments and bots
A large share of traffic on most stores comes from bots: search engine crawlers, SEO tools, monitoring services and scrapers. Many of them execute JavaScript, which means they trigger the fragments request too. On one store I worked on, more than a third of all fragments requests came from crawlers that would never buy anything.
Loading fragments only when the cart cookie exists solves this neatly, because bots don’t add products to carts. If that’s not possible with your theme, blocking known bad bots at the firewall reduces the load as a side benefit.
Testing with real devices
Mobile browsers handle session storage and back-forward caching differently from desktop. After changing how fragments load, test on an iPhone and an Android phone: add a product, use the back button, open a product in a new tab and reopen the browser after closing it. The cart count should be correct in every case, or at least correct once the visitor reaches the cart page. If it isn’t, adjust which pages load the script.
Talk to your theme developer
If your theme forces cart fragments on every page, raise it with the developer. Many theme authors have already added options to load fragments conditionally or to use the Store API instead, and those options are safer than custom code because they’re tested with the theme’s own cart features. Most stores can tame WooCommerce cart fragments in an afternoon and see the benefit immediately in server load.
Frequently asked questions
Will disabling cart fragments break my checkout?
The checkout page itself doesn’t depend on cart fragments. But the mini cart and cart count might show stale information on other pages. Test the full journey.
Why does the request take so long?
It loads all of WordPress, WooCommerce and every active plugin, then calculates the cart. Stores with many plugins or slow hosting see the longest times.
Does a CDN help with cart fragments?
Not directly. The request must reach your server because it’s personalised. It’s one reason that stores with full-page CDN caching still see server load.
My theme doesn’t show a mini cart. Do I need fragments at all?
Possibly not. If nothing on the page displays cart contents, you can usually remove the script safely. Test add-to-cart behaviour on shop pages first.




