Optimize Caching
Configuring Cloudflare's cache for optimal performance.
Cache Rules (Recommended)
Use Cache Rules (replacing Page Rules) for fine-grained control:
{
"description": "Cache static assets for 30 days",
"expression": "http.request.uri.path contains \"/static/\"",
"actions": {
"cache_ttl": {
"override_ttl": 2592000
},
"edge_ttl": {
"override_ttl": 2592000
}
}
}
Best Practices
- Set appropriate Cache-Control headers on your origin
- Leverage Tiered Cache to reduce origin requests
- Use Cache Reserve for long-tail content
- Purge cache selectively by URL, tag, or hostname
- Exclude dynamic content from caching
Related
- Cdn — CDN fundamentals
- Cloudflare — Platform overview