Misconfigured CDN caching rules
- Caching
Problem Summary
Misconfigured CDN caching rules cause the CDN to either not cache content (passing everything to origin) or serve stale content. Proper rules ensure optimal caching behavior.
Performance Impact
- Origin overload: CDN passes requests to origin instead of serving
- Stale content: Users see outdated pages
- No cache benefit: CDN provides little value
- Inconsistent performance: Cached vs uncached responses vary
How to Detect
- CDN dashboard: Check cache hit ratio
- Chrome DevTools: Check CF-Cache-Status header (Cloudflare)
- Test from multiple locations: Inconsistent cache behavior
Solutions
1. Set Appropriate Cache Rules
# Cloudflare Page Rules*.example.com/* Cache Level: Cache Everythingexample.com/index.html Edge Cache TTL: 1 hour2. Set Cache-Control Headers
<?php
add_action('send_headers', function() { header('Cache-Control: public, max-age=86400');});3>Configure CDN for HTML
Don’t forget to cache HTML pages, not just assets.
4. Purge on Update
Set up cache purging when content updates.