HomeMethod

Knowledge

Web VitalsTechniquesSnippetsAnswersImpactsBottlenecks

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

  1. CDN dashboard: Check cache hit ratio

  2. Chrome DevTools: Check CF-Cache-Status header (Cloudflare)
  3. Test from multiple locations: Inconsistent cache behavior

Solutions

1. Set Appropriate Cache Rules

Code
# Cloudflare Page Rules*.example.com/* Cache Level: Cache Everythingexample.com/index.html Edge Cache TTL: 1 hour

2. Set Cache-Control Headers

Code
<?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.

Further Reading

Support our family now