Skip to main content

CDN Cache

A CDN reduces global latency by serving content from edge locations closer to the visitor. For WordPress, the best results usually come from combining:

  • CDN caching for static assets (always)
  • CDN caching for HTML (public pages only, with strict bypass rules)
  • Origin page cache (server cache) so cache misses are still fast

What to Cache at the Edge

Content TypeCache at Edge?Notes
Images/CSS/JS/fontsYesLong TTL + versioning is ideal
Public HTMLOftenRequires careful bypass rules
Admin/account/cart/checkoutNoPrefer BYPASS / no-store

Safe Bypass Rules (WordPress + WooCommerce)

Typical bypass targets:

  • Paths: /wp-admin*, /wp-login.php*, /cart*, /checkout*, /my-account*
  • Query parameters: add-to-cart actions
  • Cookies: authenticated sessions (example: wordpress_logged_in_)
caution

If you cache HTML without cookie-aware bypass, you can serve cached pages to logged-in users.

Tiered Cache and Stale-While-Revalidate

  • Tiered cache improves global hit rate by letting edge nodes consult a regional cache before the origin.
  • Stale-while-revalidate can serve the previous cached HTML quickly while the CDN refreshes in the background.

Use these features when you publish frequently and want stable edge performance.

Purge Strategy

Prefer purging by URL (or tags, if your CDN supports it) rather than "purge everything":

  • Purge the changed page
  • Purge related listing pages (home, category archives)

Verification

curl-check-cdn-cache.sh
curl -I https://example.com/

Common CDN signals vary by provider. For Cloudflare you often see:

cloudflare-cache-status.txt
cf-cache-status: HIT

For bypassed routes (example checkout):

curl-check-cdn-bypass.sh
curl -I https://example.com/checkout/
cloudflare-bypass.txt
cf-cache-status: BYPASS

What's Next