WooCommerce Accelerator

Optimize your WooCommerce store with e-commerce-aware caching.


Overview

The WooCommerce preset extends the WordPress preset with e-commerce-specific handling. It ensures product pages are cached while shopping carts, checkout, and customer accounts remain dynamic.


Quick Setup

  1. Create a new Accelerator with the WooCommerce preset
  2. Configure your store URL as the origin
  3. Point your domain to the accelerator
  4. Test the shopping flow

What Gets Cached

Cached by default:

  • Homepage
  • Product pages
  • Product category pages
  • Shop page
  • Static pages (About, Contact, etc.)

What Bypasses Cache

The WooCommerce preset bypasses:

WordPress Paths

  • /wp-admin/*
  • /wp-login.php

WooCommerce Paths

  • /cart/*
  • /checkout/*
  • /my-account/*
  • /?add-to-cart=*
  • /?remove_item=*

WooCommerce Cookies

  • woocommerce_cart_hash
  • woocommerce_items_in_cart
  • wp_woocommerce_session_*
  • woocommerce_recently_viewed

When any of these cookies are present with a value, cache is bypassed automatically.


Cart & Checkout Flow

How It Works

  1. Visitor browses products - Cached pages, fast loading
  2. Adds item to cart - Cookie is set, cache bypassed
  3. Views cart - Dynamic page, sees cart contents
  4. Completes checkout - Fully dynamic flow
  5. Returns later (no cart) - Back to cached pages

Mini-Cart Updates

For AJAX mini-cart updates to work:

  1. Use WooCommerce AJAX cart fragments
  2. Cart widget updates via JavaScript
  3. No server-side rendering needed for cart count

Product Page Optimization

Variant Caching

By default, product variants use the same cached page. The variant selection happens via JavaScript.

If your theme requires different URLs for variants:

/product/t-shirt/?color=red
/product/t-shirt/?color=blue

Enable query string caching in your accelerator settings.

Stock Status

Stock status on cached pages may be stale. Options:

  1. JavaScript update - Fetch stock via AJAX on page load
  2. Short TTL - Cache products for 5-15 minutes
  3. Purge on stock change - Use webhook to purge when inventory changes

Price Updates

Cached pages show prices at cache time. For price updates:

Option 1: Purge on Price Change

Use a webhook or cron to purge when prices change:

add_action('woocommerce_product_set_price', function($product) {
    // Trigger CDN purge for this product
    wp_remote_post('https://nordiccdn.com/api/v1/zones/{uuid}/purge', [
        'body' => json_encode([
            'type' => 'path',
            'paths' => ['/product/' . $product->get_slug() . '/']
        ])
    ]);
});

Option 2: JavaScript Price Fetch

Load current prices via AJAX after page load.


Sale Events

For flash sales with high traffic:

  1. Pre-cache sale pages - Request pages before sale starts
  2. Enable Waiting Room - Queue visitors if needed
  3. Increase cache TTL - During high traffic
  4. Monitor origin load - Watch for cache misses

See Waiting Room for queue management.


Best Practices

1. Use Product Categories Wisely

Group products by category for efficient cache purging:

# Purge entire category
curl -X POST ".../purge" -d '{"type": "path", "paths": ["/product-category/sale/*"]}'

2. Separate Static Assets

Use a Pull Zone for WooCommerce assets:

// functions.php
add_filter('woocommerce_enqueue_styles', function($styles) {
    // Rewrite to CDN URLs
    return $styles;
});

3. Handle Recently Viewed

The woocommerce_recently_viewed cookie triggers cache bypass. Options:

  1. Disable recently viewed products
  2. Load via JavaScript (recommended)
  3. Accept cache bypass for these visitors

4. Test the Full Flow

Before going live, test:

  • [ ] Browse products (should be cached)
  • [ ] Add to cart (should bypass)
  • [ ] View cart (should be dynamic)
  • [ ] Complete checkout (should work)
  • [ ] Log in as customer (should bypass)
  • [ ] Return with empty cart (should cache)

Troubleshooting

Cart Not Updating

If cart shows wrong items:

  1. Check WooCommerce AJAX cart fragments are enabled
  2. Verify JavaScript is loading properly
  3. Check for caching plugins conflicting

Checkout Errors

If checkout fails:

  1. Verify /checkout/* is in bypass paths
  2. Check that session cookies are being passed
  3. Ensure HTTPS is configured correctly

Logged-In Customers See Cached Content

  1. Verify wordpress_logged_in_* cookie is present
  2. Check /my-account/* is in bypass paths
  3. Clear browser cache and test again