Skip to main content

ESI for WooCommerce

WooCommerce adds per-user state (cart contents, account links, nonces) that can reduce your page-cache hit rate. ESI (Edge Side Includes) is a pattern that lets you cache most of the page while rendering a small fragment dynamically.

When You Need ESI

Consider ESI when:

  • Public product/category pages are not caching because cart cookies force bypass
  • You want cached pages, but still need a live mini-cart count or user-specific widget

Prerequisites

ESI requires an ESI-capable caching layer. In the WordPress ecosystem this is commonly LiteSpeed Enterprise + LSCache.

note

If you are on OpenLiteSpeed or Nginx without an ESI solution, you can still get most benefits by caching public pages and bypassing cart/checkout/account routes.

What to Put Behind ESI

Good ESI candidates are small, frequently changing, per-user fragments:

  • Mini-cart/cart count
  • Logged-in greeting/account widget
  • Wishlist count (if it changes per user)

Avoid making large parts of the page ESI (it reduces the benefit of caching).

Verification

  1. Confirm the page itself is cached for guests.
  2. Confirm the ESI fragment updates per session.
  3. Test two separate sessions (incognito windows) and verify cart counts do not leak.

Header signal (LiteSpeed example):

curl-check-esi-header.sh
curl -I https://example.com/shop/ | grep -i x-litespeed-cache-control

Example output:

litespeed-esi-on.txt
x-litespeed-cache-control: esi=on

Common Pitfalls

PitfallRiskFix
Treating per-user fragments as publicData leakage / wrong cart countsUse private ESI for per-user content
Purging everything on cart eventsLow hit ratePurge selectively and keep ESI fragments small
Caching cart/checkout pagesBroken checkoutExclude /cart, /checkout, /my-account

What's Next