Skip to content
super-page-cache

Instant speed boost – enable lazy-loading, defer scripts, and fine-tune caching for blazing-fast pages. Priority support included.

See Pro Plans →

How to Optimize cache for WooCommerce Stores

WooCommerce stores present unique caching challenges due to their dynamic nature—shopping carts, user accounts, checkout processes, and personalized content. This comprehensive guide will show you how to configure Super Page Cache to maximize performance while maintaining full e-commerce functionality.

Understanding WooCommerce Caching Challenges

Why E-commerce Caching is Complex

Dynamic Content Requirements:

  • Shopping cart contents change per user
  • Product prices may vary by user role or location
  • Inventory levels update in real-time
  • Personalized recommendations and recently viewed products
  • User-specific account information and order history

Critical Pages That Need Special Handling:

  • Cart and checkout pages (must never be cached)
  • My Account dashboard (user-specific content)
  • Product pages with dynamic pricing
  • Category pages with stock status
  • Search results and filters

Step-by-Step WooCommerce Optimization

  1. Navigate to Super Page Cache → Compatibilities

  2. Under the WooCommerce Settings, you can exclude the WooCommerce Page types.

  3. You can take advantage of additional settings listed there as well.

⚠️ Important: The Automatically purge cache for product page and related categories when stock quantity changes setting purges the product page and all parent category and archive URLs on every stock update.

On stores with more than 10,000 products, a single stock change can trigger 600 or more URL purges simultaneously, causing:

  • High server load and PHP timeouts
  • Cloudflare API rate limit errors
  • Slow or failed admin stock edits

If your store has a large catalog, disable this setting and use a targeted purge instead — see Troubleshooting Stock Update Performance Issues below.

  1. Configure Critical Page Exclusions

Go to Super Page Cache → General and under the Prevent the following URIs to be cached setting, you can exclude the following URLs from cache to ensure dynamic content is not cached.

Recommended (Verify these are enabled):

/cart/*
/checkout/*
/my-account/*
/wc-api/*
/?wc-ajax=*
/?add-to-cart=*
/?remove_item=*

Additional Manual Exclusions:

/shop/?orderby=*
/shop/?min_price=*
/shop/?max_price=*
/?s=* (search results)
/wishlist/* (if using wishlist plugins)
/compare/* (if using product comparison)

Troubleshooting WooCommerce Cache Issues

Common Issue 1: Cart Not Updating

Symptoms:

  • Items remain in cart after removal
  • Cart totals don't update
  • Mini cart shows incorrect quantities

Solutions:

  1. Clear Cart-Related Cache:
Exclude these patterns:
/?wc-ajax=add_to_cart
/?wc-ajax=remove_from_cart
/?wc-ajax=get_refreshed_fragments
  1. Configure these settings:

- Enable "Auto-purge on Stock Change"

Troubleshooting Stock Update Performance Issues

Symptoms:

  • Editing product stock levels causes PHP timeouts or very slow admin responses (visible in WooCommerce → Orders or the product edit screen)
  • High server CPU or memory spikes whenever inventory is updated (check your hosting control panel or server monitoring tool)
  • Cloudflare API rate-limit errors appearing in Super Page Cache logs or your Cloudflare dashboard after bulk stock changes
  • A large number of cache-purge requests logged per single stock edit (check your PHP error log or Super Page Cache debug log)

Why this happens:

The Automatically purge cache for product page and related categories when stock quantity changes setting purges the product page and every parent category, archive, and related URL when stock is updated. On stores with a large catalog, one stock change can trigger 600 or more URL purges simultaneously, overwhelming the server and hitting Cloudflare API limits.

Solution:

  1. Go to Super Page Cache → Compatibilities → WooCommerce.
  2. Disable Automatically purge cache for product page and related categories when stock quantity changes.
  3. Add the following code to a site-specific plugin (recommended) or your theme's functions.php file to replace the broad purge with a targeted one that clears only the updated product page and its direct categories:
php
add_action( 'woocommerce_update_product_stock', function( $product_id ) {
    $product = wc_get_product( $product_id );
    if ( ! $product ) {
        return;
    }

    $urls = [ $product->get_permalink() ];

    $terms = wp_get_post_terms( $product_id, 'product_cat', [ 'fields' => 'all' ] );
    foreach ( $terms as $term ) {
        $link = get_term_link( $term );
        if ( ! is_wp_error( $link ) ) {
            $urls[] = $link;
        }
    }

    do_action( 'super_page_cache_purge_urls', $urls );
}, 10, 1 );

💡 Tip: Test this code on a staging environment before deploying to production to confirm the targeted purge works as expected for your store setup.


Congratulations! You've successfully optimized Super Page Cache for your WooCommerce store. Your customers should now experience significantly faster page loads while maintaining full e-commerce functionality, leading to improved conversions and better search engine rankings.

Remember to monitor your store's performance regularly and adjust cache settings based on your specific traffic patterns and business needs.