Disable WooCommerce Cart Fragments
Often slow performance and errors on WooCommerce sites are caused by a high number of AJAX requests, as these requests are uncached. If you are running a WooCommerce site on WP Engine and notice a high number of AJAX requests, disabling Cart Fragments AJAX may help improve your site’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 site 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 site with any web page speed test,or your site’s Access Log by adding the following query argument to your domain:
The Cart Fragments will appear as follows in your Access Log:
31/Dec/2017:23:59:59 +0000|v1|188.8.131.52|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 site 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 site from dropped connections under continuous load. Live Cart is not only faster, but it makes the server more stable and responsive in peak traffic.
Option 2: Disable Cart Fragments
Disabling Cart Fragments will remove the real-time cart functionality but will reduce overall server load and protect your site’s scalability. There are a few ways of disabling WooCommerce Cart Fragments.
- Add a plugin with a cart fragmentation disabling feature, such as “Disable Cart Fragments” or “Perfmatters”, to your site.
- Follow this guide to disable cart fragmentation through editing the
functions.phpfile of your theme.
NEXT STEP: Read about WooCommerce Best Practices