Site AI Auditvon Internet Solutions

WooCommerce Cart Fragments: Fix the Slow wc-ajax Request

3. November 20268 Min. LesezeitWebsite-Geschwindigkeit
WooCommerce Cart Fragments: Fix the Slow wc-ajax Request

Short answer: Cart fragments are a WooCommerce feature that updates the mini cart in your header through a background request named get_refreshed_fragments. The request cannot be served from a page cache, so on a busy shop it can use a surprising share of server power. You can measure it in the browser, and then reduce it by simplifying the header cart, limiting where the script loads or improving the server behind it.

What cart fragments are

A shop page is usually stored in a cache so that it can be served quickly to many visitors. A cart, however, is personal. One visitor has two items, another has none. If the cached page contained a cart count, the next visitor would see someone else’s number.

WooCommerce solves this with a script, called cart fragments. The page itself is the same for everyone. After it loads, the script asks the server for the current cart contents through a request to an address ending in ?wc-ajax=get_refreshed_fragments, and it replaces the small cart area in the header with the result. The answer is also stored in the browser’s session storage, so repeated visits to pages do not always need a new answer.

Why it can slow a shop down

Recent WooCommerce versions have reduced how often the script loads, but themes that show a cart widget in the header still rely on it. Test your own site instead of assuming.

How to measure it

  1. Open a normal page of your site in a private window, so that no cart exists.
  2. Open the developer tools and go to the network tab. Filter for “wc-ajax”.
  3. Reload the page. If you see a request named get_refreshed_fragments, note its time. A fast shop answers in well under a second. A slow one takes one or two seconds or more.
  4. Add a product to the cart and reload. The request may run again, and the answer will contain more data.
  5. Open a page that has nothing to do with shopping, such as a contact page. If the request still appears, the script loads everywhere.

On the server side, look at the access log for requests to wc-ajax. If they make up a large share of all requests, they deserve attention. The article on admin-ajax.php high usage shows a similar way to investigate background requests, and the guide to the waterfall chart helps to read the timing.

Options to reduce the load

Simplify the header cart

Often the best fix is a design change. Replace the mini cart drop-down with a simple link to the cart page. If the link does not need a live count, no extra request is required. Some stores keep a small count that is updated only after a visitor adds something, which uses far fewer requests.

Load it only where it is needed

A developer can stop the script from loading on pages that do not show the cart or are not part of the shopping flow, such as blog posts and information pages. Several performance plugins offer this as a setting. Test carefully: if the count disappears or does not update after an addition, the change is too aggressive.

Make the answer faster

Avoid unsafe shortcuts

Do not exclude the wrong pages from caching or disable the script on the cart and checkout pages. Those pages must stay dynamic and accurate, and breaking them costs sales. A change that makes the home page faster and the checkout unreliable is not an improvement.

What to cache and what not to cache

A shop needs a careful caching setup. Product, category and information pages can be cached for visitors without a cart. The cart, checkout and account pages must never be served from a shared page cache, and your caching plugin should exclude them by default. Check that the cookies that WooCommerce sets for visitors with a cart are respected. The general idea is explained in the article on page caching, and the broader checklist in the guide to speeding up a WooCommerce store.

A practical order of work

Shop owners often try everything at once and learn nothing. A calmer sequence gives clearer results and protects sales.

  1. Record a baseline. Note the response time of the fragments request and the load time of two typical pages: the home page and a product page. Save the numbers with the date.
  2. Take a backup and use a staging copy. Changes to scripts and caching rules should be tried away from the live shop first.
  3. Change the design before the code. If a simple cart link is acceptable to your brand, that single change removes the request on most pages and needs no maintenance.
  4. Limit where the script loads. If you must keep the mini cart, restrict the script to the pages where it is visible and test the whole path from product page to payment.
  5. Improve the server answer. Add an object cache, update PHP and remove plugins you do not use.
  6. Measure again. Repeat the same tests under the same conditions. Keep the change only if the numbers improved and the shop works.
  7. Watch real orders. For a week after the change, compare the number of carts created and orders completed with the previous week. A faster shop that sells less is a bad trade.

Document the result in a few lines for whoever maintains the shop next. Theme or plugin updates can bring the old behaviour back, and a short note saying what you changed and why makes it easy to repeat the fix.

If you run a very small shop, you may find that the request costs little and that the best use of your time is elsewhere, such as compressing product images or removing an unused slider. The aim is a faster experience for buyers, not a perfect list of requests. Fix the largest cause of slowness first, and stop when the pages feel quick on a phone.

Common mistakes

How Site AI Audit helps

Site AI Audit does not look inside your shop’s AJAX requests. It measures the visitor-facing result: the Google PageSpeed score, loading metrics such as LCP, CLS and INP, server response time, compression and page weight, so you can see whether pages are slow before and after a change. The first check is free, covers up to 50 pages and needs no sign-up. You can run a free check of your website or see the plans for weekly monitoring and alerts.

Related reading

The bottom line

Cart fragments solve a real problem, but they can cost a lot when they run on every page. Measure the request, simplify the header cart where you can, load the script only where it matters and keep cart and checkout pages dynamic and correct.

FAQ

What does wc-ajax=get_refreshed_fragments do?

It returns the current mini cart contents for the visitor, so that cached pages can still show a correct cart count.

Is it safe to disable cart fragments?

On pages without a cart widget, usually yes. Where a mini cart is shown, disabling it can leave a wrong count. Test adding a product afterwards.

Why is the request slow on my site?

It starts WordPress and runs plugins. Many plugins, slow hosting or a missing object cache make it slower.

Does a page cache fix it?

No. The request is dynamic by design and is not served from a page cache. You can only reduce how often it runs or make it faster.

Will removing the mini cart hurt sales?

A clear cart link and a visible add-to-cart confirmation are usually enough. Test with real visitors and watch your orders.

#Page speed#WooCommerce#WordPress performance
Prüfen Sie Ihre eigene Website — kostenlos.Was Sie auf Ihrer Website beheben sollten — und wo Sie anfangen.
Kostenlos starten

Mehr aus dem Blog

Alle Artikel →
Internet Solutions

Mehr von unserem Team

Entwickelt von Internet Solutions. Probieren Sie auch unsere anderen Produkte aus — jedes spart Ihnen auf seine eigene Weise Zeit.

internet-solutions.net ↗