How to Use CDN-Cache-Control vs. Cache-Control on Cloudflare Without Serving Stale Pages
One of the most frustrating caching bugs happens when you publish an edit, purge Cloudflare’s cache, reload your site, and still see the old version in your browser—or worse, visitors see yesterday’s article for hours. In most cases, the culprit is a single Cache-Control: public, max-age=86400 header telling both Cloudflare’s edge and the visitor’s browser to keep the HTML for 24 hours. Purging Cloudflare clears the edge, yet you cannot reach into a visitor’s browser cache to delete that copy.
Editorial illustration: keep browser max-age short while giving Cloudflare a longer, purgeable edge TTL via CDN-Cache-Control.
Summary
CDN-Cache-Controllets your origin server set caching rules specifically for CDNs without forcing visitor browsers to hold stale copies.- Use
Cloudflare-CDN-Cache-Controlwhen you want Cloudflare alone to follow a distinct policy while leaving other downstream CDNs or browsers untouched. - Setting
Cloudflare-CDN-Cache-Controlautomatically activates Origin Cache Control (OCC) for that response on Cloudflare. - For HTML pages, a practical pattern is a short browser
Cache-Control(max-age=60ormust-revalidate) paired with a longerCDN-Cache-Control(max-age=3600ors-maxage) that you purge on publish.
Why a single Cache-Control header causes stale-page headaches
Standard Cache-Control is shared by every cache along the path: your origin proxy, Cloudflare’s edge nodes, corporate proxies, and the visitor’s browser.
- If you set
max-age=30to keep edits fresh, Cloudflare hits your origin server every 30 seconds for every edge data center, wasting origin CPU. - If you set
max-age=86400to offload traffic to Cloudflare, browsers also cache the HTML locally for 24 hours. When you fix a typo and purge Cloudflare, returning visitors still read their local browser cache until the 24-hour timer expires.
How CDN-Cache-Control and Cloudflare-CDN-Cache-Control solve it
Per Cloudflare’s CDN-Cache-Control documentation, Cloudflare evaluates caching headers in a clear order when no overriding Cache Rule takes precedence:
Cloudflare-CDN-Cache-Control: Highest specificity for Cloudflare’s edge. Setting this header also turns Origin Cache Control on for that response, as noted in Cloudflare’s Origin Cache Control docs.CDN-Cache-Control: Standard header respected by Cloudflare and other supporting CDNs, while ignored by end-user browsers.Cache-Control: Governs the visitor’s browser (and acts as the fallback if no CDN-specific header is sent).
That separation lets you tell browsers “check back often” while telling Cloudflare “cache this at the edge until we purge it or the edge TTL expires.”
Step-by-step: Configure split browser and edge caching
1. Choose safe lifetimes for HTML vs. static assets
- HTML pages (blog posts, landing pages):
Browsers recheck after 60 seconds (often receiving a fastCache-Control: public, max-age=60, must-revalidate CDN-Cache-Control: public, max-age=3600304 Not Modifiedor a fresh edge copy), while Cloudflare serves cached HTML for up to an hour—or until your CMS purges the URL. - Versioned static assets (hashed CSS, JS, images):
Because filenames change on every build (for example,
styles.abc123.css), both headers can safely usepublic, max-age=31536000, immutable.
2. Avoid caching personalized or authenticated responses
Never emit public in CDN-Cache-Control on logged-in WordPress admin pages, WooCommerce carts, or personalized Drupal routes. As Cloudflare’s cache responses documentation highlights, sending no-store or private in CDN-Cache-Control or Cloudflare-CDN-Cache-Control prevents Cloudflare from caching sensitive responses.
3. Check Cloudflare Cache Rules for overrides
Remember that a Cloudflare Cache Rule configured in the dashboard can override origin headers (for example, Edge Cache TTL rules). If your origin sends CDN-Cache-Control: max-age=3600 but cf-cache-status still shows DYNAMIC or an unexpected age, inspect your zone’s Caching > Cache Rules to see which rule matched first.
4. Verify with curl -I before and after purging
Test your live headers from a terminal:
curl -I https://example.com/blog/sample-post/
Inspect cache-control, cdn-cache-control, cf-cache-status (HIT, MISS, EXPIRED, or DYNAMIC), and age. If a page still looks stale after updating your origin, follow our checklist on purging a stale page on Cloudflare and check how to enable Cloudflare HSTS safely. If you run Drupal behind Cloudflare, also verify your origin tags using Drupal cache tag debugging.
Common mistakes
- Setting
Cache-Control: max-age=86400on HTML and expecting a Cloudflare purge to update returning visitors’ browsers. Cloudflare purges only clear Cloudflare’s edge, not browser caches on visitors’ phones. - Using
CDN-Cache-Controlon unversioned CSS/JS without a purge workflow. If you deploy a CSS change without a filename hash or query string version, stale edge copies will linger untilmax-ageexpires. - Forgetting
Origin Cache Controlbehavior on custom setups. If your Cache Rules forceIgnore Cache-Control, your origin headers may be bypassed unless you align your dashboard rule or useCloudflare-CDN-Cache-Control. - Caching
Set-Cookieresponses accidentally. Always bypass or mark authenticated endpointsprivate, no-storeso one user’s session never hits shared edge storage.
Why this matters
Fast sites need high edge cache hit ratios, yet editorial blogs and business sites also need typos, prices, and security notices to update within minutes of publishing. Separating browser TTL from CDN TTL gives you both fast edge delivery and predictable updates.
My Take
For almost every content site on Cloudflare, keeping browser Cache-Control short (60 to 300 seconds) on HTML while letting CDN-Cache-Control handle the heavy lifting at the edge (3600 seconds or more with tag/URL purging) is the cleanest setup. Reserve long 1-year max-age values strictly for fingerprinted CSS, JavaScript, and image assets.
Conclusion
Send a short Cache-Control header for browsers alongside a longer CDN-Cache-Control or Cloudflare-CDN-Cache-Control header for Cloudflare’s edge on HTML responses, keep authenticated pages private, no-store, and verify cf-cache-status and age with curl -I after every rule change.