Knowledgebase

How to speed up a WooCommerce store (cart fragments, database cleanup and HPOS)

A slow store loses sales, especially on mobile. Many WooCommerce-specific slowdowns are not fixed by general WordPress tips alone. This guide shows how to speed up a WooCommerce store with page caching, cart fragments, database cleanup and HPOS (High-Performance Order Storage). Start with the basics in How to Speed Up Your WordPress Website first.

Before any change: take a full backup (How to back up and restore your website), and test on a quiet time of day. Measure before and after with a tool such as PageSpeed Insights, so you know what helped.

Step 1: Use page caching correctly

  1. EgWeb hosting runs on LiteSpeed, so install and activate the LiteSpeed Cache plugin.
  2. Turn caching on. LiteSpeed Cache automatically excludes the cart, checkout and my-account pages, and serves cached pages only to visitors with an empty cart.
  3. Enable image lazy loading and CSS/JS optimisation carefully, one option at a time, and test the add-to-cart and checkout after each change.

Step 2: Handle cart fragments

Cart fragments is a WooCommerce script that calls ?wc-ajax=get_refreshed_fragments to update the mini-cart count. On some sites it runs on every page and slows the first load. Recent WooCommerce versions only load it when a mini-cart needs it, but many themes still load it everywhere.

  1. Open your homepage, press F12, go to the Network tab and look for get_refreshed_fragments.
  2. If it appears on pages that do not need a live cart count, you can stop it there with this snippet (Code Snippets plugin or child theme):
add_action( 'wp_enqueue_scripts', function () {
// Stop cart fragments on the homepage and blog posts only
if ( is_front_page() || is_singular( 'post' ) ) {
wp_dequeue_script( 'wc-cart-fragments' );
}
}, 100 );

Test afterwards: add a product to the cart and check the header cart count still updates on the shop and product pages. If your theme's header cart stops working, remove the snippet.

Step 3: Clean the database

  1. Go to WooCommerce → Status → Tools and run Clear transients and Clear expired transients.
  2. Go to WooCommerce → Status → Scheduled Actions. Thousands of Pending or Past-due actions mean background tasks are not running; set up a real cron job (ask support). Very old completed and failed actions can be cleaned with a trusted cleanup plugin.
  3. Delete old post revisions, spam comments and trashed items with the LiteSpeed Cache database tool or a cleanup plugin such as WP-Optimize.
  4. Limit future revisions by adding this line to wp-config.php, above the "That's all, stop editing" line:
define( 'WP_POST_REVISIONS', 5 );

Also remove plugins you do not use, and check that old plugins have not left large tables or autoloaded options behind.

Step 4: Switch to HPOS

HPOS stores orders in dedicated tables instead of the general WordPress posts tables. It makes order queries faster, especially for stores with many orders. New stores use it by default; older stores may still be on the legacy storage.

  1. Go to WooCommerce → Settings → Advanced → Features.
  2. Under Order data storage, check which option is selected. WooCommerce warns you if an active plugin is not compatible with HPOS. Update or replace those plugins first.
  3. Enable compatibility mode (it keeps both storage types in sync) and wait until the sync of existing orders finishes.
  4. Select High-performance order storage and save.
  5. Test: place an order, edit an order, and check that your payment, shipping and invoice plugins still work.
  6. After some days without problems, you can turn compatibility mode off.

Step 5: Server-side improvements

  • Use the latest PHP version your plugins support: How to change the PHP version.
  • Ask support whether object caching (Redis or Memcached) is available for your plan; it helps busy stores with logged-in customers.
  • Large catalogues and high traffic may need more CPU and RAM than a shared plan: consider a VPS.

Common problems

  • Cart empties or shows wrong items: a cache rule is caching cart or checkout. Purge all cache and review custom exclusions.
  • Admin orders page is slow: legacy order storage with many orders, or a plugin adding heavy columns. Move to HPOS and disable unneeded admin plugins.
  • Site broke after JS optimisation: turn off JS combine/defer, then enable options one by one.

Frequently asked questions

Is HPOS safe to enable?

Yes, it is WooCommerce's recommended storage. The risk is incompatible plugins, so check the compatibility warning, use compatibility mode, and keep a backup.

Should I use more than one caching plugin?

No. Use one page cache (LiteSpeed Cache on our servers). Two caching plugins often conflict.

Need help? Open a support ticket or message us on WhatsApp +20 127 113 3655.

  • woocommerce, speed, performance, cart fragments, hpos, database, litespeed cache

Was this answer helpful?

0 Users Found This Useful