Disable WooCommerce Cart Fragments

Often slow performance and errors on WooCommerce stores are caused by a high number of AJAX requests, as these requests are uncached. If you are running a WooCommerce store on WP Engine and notice a high number of AJAX requests, disabling Cart Fragments AJAX may help improve your store’s stability.


About WooCommerce Cart Fragments

WooCommerce “Cart Fragments” is a script using admin ajax to update the cart without refreshing the page. This functionality will slow down the speed of your store or break caching on pages that don’t actually require cart information.

For example, Cart Fragments on static posts, pages, custom post types and feed pages that contain no eCommerce functionality will decrease cacheability and ultimately degrade server performance.

You can identify the Cart Fragments on a store with any web page speed test, or the website’s Access Log by adding the following query argument to your domain:

http://testsite.wpengine.com/?wc-ajax=get_refreshed_fragments

The Cart Fragments will appear as follows in your Access Log:

31/Dec/2017:23:59:59 +0000|v1|1.1.1.1|www.testsite.wpengine.com|200|210|127.0.0.1:80|0.328|0.330|POST /?wc-ajax=get_refreshed_fragments HTTP/2.0||

Option 1: Enable Live Cart

Live Cart is a proprietary performance feature built into WP Engine eCommerce plans that eliminates the AJAX call from happening at unnecessary times, and improves the scalability of the cart and page speed across your entire store without losing dynamic cart functionality. The biggest benefit is seen when items are added to the cart and during high-traffic events, like a special promotion or event (like Black Friday). When a customer adds an item to the cart, Live Cart loads pages on average 1.5 seconds faster than the default Cart Fragments script and helps keep your store from dropped connections under continuous load. Live Cart is not only faster, but it makes the server more stable and responsive in peak traffic.

Live Cart is included with WP Engine eCommerce Solutions.


Option 2: Disable Cart Fragments

Disabling Cart Fragments will remove the real-time cart functionality but will reduce overall server load and protect your website’s scalability. There are a few ways of disabling WooCommerce Cart Fragments.

  1. Add a plugin with a cart fragmentation disabling feature, such as “Disable Cart Fragments” or “Perfmatters”, to your store.
  2. Follow this guide to disable cart fragmentation through editing the functions.php file of your theme.

NEXT STEP: Read about WooCommerce Best Practices

Still need help? Contact support!

We offer support 24 hours a day, 7 days a week, 365 days a year. Log in to your account to get expert one-on-one help.

The best in WordPress hosting.

See why more customers prefer WP Engine over the competition.