A slow WooCommerce store nearly always needs the same few fixes, and store owners get the most from them by applying them in a set order. WooCommerce runs on WordPress, so general WordPress tuning still helps. The store adds its own load, though. Cart and checkout pages are different for every shopper, so they cannot be cached, and product searches lean hard on the wp_postmeta table. The ?wc-ajax= requests that refresh the cart must never be cached either. Start with a Redis object cache, which keeps the results of repeated database lookups in memory. Next, set up page caching with the right pages excluded. Then move orders to HPOS (High-Performance Order Storage, WooCommerce’s dedicated order tables) once you are past a few hundred orders. Database and front-end tuning come last.
How to verify
A tuned WooCommerce store shows:
wp option get woocommerce_custom_orders_table_enabled
# yes (HPOS active)
wp redis status
# Connected, using PhpRedis
wp eval 'echo wp_cache_get("alloptions", "options") ? "cached" : "miss";'
# cached
curl -sI https://shop.example.org/ | grep -i cache
# x-cache: HIT (page cache works for non-logged-out, non-cart pages)
curl -sI "https://shop.example.org/?wc-ajax=get_refreshed_fragments" | grep -i cache
# x-cache: BYPASS (AJAX endpoint must NOT cache)
wp transient delete --all
# (transients should clear cleanly without errors)
If the AJAX cart endpoint is returning HIT, you have stale carts being served to other users — fix the cache rules immediately.
What’s happening
WooCommerce has three categories of pages: cacheable (catalog, single product, homepage) where Varnish/Nginx/Cloudflare full-page cache helps; semi-cacheable (cart, checkout, my-account) where caching breaks the user experience; and AJAX/REST endpoints (?wc-ajax=, /wp-json/wc/) that are stateful and must always bypass cache. The first 80% of performance wins are getting those rules right.
Behind that, the WordPress object cache backed by Redis or Memcached cuts thousands of database queries per request — every wp_options autoload, every get_post_meta lookup, every get_term. Without it, a catalog page is 100-200 DB queries; with it, 5-15. This is the highest-leverage single change on any WordPress site.
WooCommerce 8.x made HPOS (High-Performance Order Storage) generally available. The legacy schema stored orders as wp_posts rows with order line items in wp_postmeta — that table grows linearly with orders × meta keys and indexes badly. HPOS moves orders to dedicated tables (wp_wc_orders, wp_wc_order_addresses, wp_wc_order_operational_data) with proper indexes. Migration is one CLI command, and the difference on stores past 10k orders is dramatic.
The procedure
-
Turn on Redis object cache. Install
redis-serverand the WP plugin:sudo apt install -y redis-server php-redis wp plugin install redis-cache --activate wp redis enable wp redis statusVerify in
wp-config.phpthatWP_CACHE_KEY_SALTis set to your domain (otherwise multiple sites collide on the same Redis). -
Configure page cache with the correct exclusions. If using Cloudflare APO, Nginx FastCGI cache, or Varnish, exclude:
/cart/,/checkout/,/my-account/,/wc-api/,/?add-to-cart=- Cookies:
wordpress_logged_in_*,woocommerce_cart_hash,woocommerce_items_in_cart,wp_woocommerce_session_* - Any URL with
wc-ajax=query param
Example Nginx FastCGI cache rule:
set $skip_cache 0; if ($request_uri ~* "/(cart|checkout|my-account|wc-api|addons)/") { set $skip_cache 1; } if ($arg_wc_ajax) { set $skip_cache 1; } if ($http_cookie ~* "wordpress_logged_in|woocommerce_items_in_cart") { set $skip_cache 1; } fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; -
Migrate to HPOS. This is a one-way migration (you can technically revert but it’s painful):
wp wc cot count_unmigrated wp wc cot sync --batch-size=500 wp option update woocommerce_custom_orders_table_enabled yes wp option update woocommerce_custom_orders_table_data_sync_enabled no wp transient delete --allRun during a maintenance window — the migration locks the orders table.
-
Index your custom postmeta keys. If you use ACF or any plugin that filters products by meta, add indexes:
ALTER TABLE wp_postmeta ADD INDEX idx_meta_key_value (meta_key(20), meta_value(20));Don’t add the index on a busy production DB; do it via
pt-online-schema-changeor a maintenance window. -
Tune MySQL for WooCommerce write patterns.
# /etc/mysql/mariadb.conf.d/woocommerce.cnf innodb_buffer_pool_size = 4G # ~70% of available RAM on a dedicated DB host innodb_flush_log_at_trx_commit = 2 innodb_flush_method = O_DIRECT query_cache_type = 0 # always off on InnoDB max_connections = 300 -
Defer non-critical JS. WooCommerce ships a lot of scripts — many are not used outside cart/checkout. Use a plugin like
WP Rocketor hand-roll dequeues:add_action('wp_enqueue_scripts', function() { if (!is_woocommerce() && !is_cart() && !is_checkout() && !is_account_page()) { wp_dequeue_style('woocommerce-general'); wp_dequeue_script('wc-add-to-cart-variation'); wp_dequeue_script('jquery-blockui'); } }, 99); -
Audit slow queries. Enable the slow query log:
# /etc/mysql/mariadb.conf.d/slow.cnf slow_query_log = 1 long_query_time = 0.5 slow_query_log_file = /var/log/mysql/slow.logRun
pt-query-digest /var/log/mysql/slow.logweekly; the top entries are usuallywp_options autoload(fix with the object cache) and unindexed product searches (fix with a proper search engine like ElasticPress). -
Audit transients. WooCommerce stores cart fragments, product variations cache, and shipping zones as transients — when the option cache pile grows, the autoload query gets slow:
SELECT option_name, LENGTH(option_value)/1024 AS kb FROM wp_options WHERE autoload='yes' ORDER BY kb DESC LIMIT 10;Look for anything over 200 KB; those are usually plugin transients that should not be autoload.
Common pitfalls
- Object cache enabled but
wp_options.autoloadrows over 1 MB total — the cache helps but cold cache from a Redis flush hits MySQL hard. Keep autoload tight. - Caching the AJAX cart endpoint serves one user’s cart to another. Test with two browsers immediately after deploying cache rules.
- HPOS sync disabled but the legacy tables aren’t dropped — they still get written to by old code. After migration, monitor for
wp_postsrows withpost_type = shop_orderfor a week, then disable the legacy storage explicitly. - Cloudflare APO can break the WooCommerce sessions cookie if your origin sets it on every request — pin the session cookie name in the APO exception list.
- WooCommerce REST API auth is expensive — every
/wp-json/wc/v3/orderscall hits the user table and does an HMAC check. Cache the auth result in Redis for the duration of the request if you’re proxying through an integration layer.
For stores running WooCommerce in production, Stack Harbor operates the full performance surface — Redis object cache configured and monitored, page cache rules audited at every release, HPOS migration planned and executed, MySQL backed up and PITR-capable — so the marketing team sees a fast site without owning the tuning. That model lives under managed operations, with related Headless WordPress notes alongside.