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 Type | Cache at Edge? | Notes |
|---|---|---|
| Images/CSS/JS/fonts | Yes | Long TTL + versioning is ideal |
| Public HTML | Often | Requires careful bypass rules |
| Admin/account/cart/checkout | No | Prefer 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-cartactions - 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