CDN-Cache-Control
CDN-Cache-Control is a response header field set on the origin to separately control the behavior of CDN caches from other intermediaries that might handle a response. You can set the CDN-Cache-Control or Cloudflare-CDN-Cache-Control response header using the same directives used with the Cache-Control.
You have several options available to determine how CDN-Cache-Control directives interact with Cache-Control directives.
An origin can:
-
Return the
CDN-Cache-Controlresponse header which Cloudflare evaluates to make caching decisions.Cache-Control, if also returned by the origin, is proxied as is and does not affect caching decisions made by Cloudflare. Additionally,CDN-Cache-Controlis proxied downstream in case there are other CDNs between Cloudflare and the browser. -
Return the
Cloudflare-CDN-Cache-Controlresponse header. This results in the same behavior as the origin returningCDN-Cache-Controlexcept Cloudflare does not proxyCloudflare-CDN-Cache-Controldownstream because it’s a header only used to control Cloudflare. This option is beneficial if you want only Cloudflare to have a different caching behavior while all other downstream servers rely onCache-Controlor if you do not want Cloudflare to proxy theCDN-Cache-Controlheader downstream. -
Return both
Cloudflare-CDN-Cache-ControlandCDN-Cache-Controlresponse headers. In this case, Cloudflare only looks atCloudflare-CDN-Cache-Controlwhen making caching decisions because it is the most specific version ofCDN-Cache-Controland proxiesCDN-Cache-Controldownstream. Only forwardingCDN-Cache-Controlin this situation is beneficial if you want Cloudflare to have a different caching behavior than other CDNs downstream.
Additionally, surrogates will not honor Cache-Control headers in the response from an origin. For example, if the Surrogate-Control header is present within the response, Cloudflare ignores any Cache-Control directives, even if the Surrogate-Control header does not contain directives.
The Edge Cache TTL cache rule overrides the amount of time an asset is cached on the edge (Cloudflare data centers). This cache rule overrides directives in Cloudflare-CDN-Cache-Control/CDN-Cache-Control which manage how long an asset is cached on the edge. You can create this rule in the dashboard in Cache > Cache Rules.
The Browser Cache TTL cache rule overrides the amount of time an asset is cached by browsers/servers downstream of Cloudflare. Browser Cache TTL only modifies the Cache-Control response header. This cache rule does not modify Cloudflare-CDN-Cache-Control/CDN-Cache-Control response headers.
The origin returns the Expires response header which specifies the amount of time before an object is considered stale to the browser. This response header does not affect the caching decision at Cloudflare when Cloudflare-CDN-Cache-Control/CDN-Cache-Control is in use.
In situations where Cloudflare does not receive Cloudflare-CDN-Cache-Control, CDN-Cache-Control, or Cache-Control values, cacheable assets use the general default values.
Use CDN-Cache-Control when you want to manage cached asset’s TTLs separately for origin caches, CDN caches, and browser caches. The example below shows how you can manage your cached asset’s TTLs using origin-set response headers.
Headers:
Cache-Control: max-age=14400, s-maxage=84000Cloudflare-CDN-Cache-Control: max-age=24400CDN-Cache-Control: max-age=18000
Cache behavior:
Caches | Cache TTL (seconds) | ||||||||
|---|---|---|---|---|---|---|---|---|---|
Origin Server Cache | 14400 | ||||||||
Network Shared Cache | 84000 | ||||||||
Cloudflare Edge | 24400 | ||||||||
Other CDNs | 18000 | ||||||||
Browser Cache | 14400 |
Use CDN-Cache-Control headers in conjunction with Cache-Control headers to specify when to serve stale content in the case of error or during revalidation. The example below shows how you might set your headers and directives to apply to CDNs when handling errors.
Headers:
Cache-Control: stale-if-error=400Cloudflare-CDN-Cache-Control: stale-if-error=60CDN-Cache-Control: stale-if-error=200
Behavior in response to 5XX error:
Caches | Stale served (seconds) in response to error | ||||||||
|---|---|---|---|---|---|---|---|---|---|
Origin Cache Layer/Network Cache/Browser Cache | 400 (if it assumes the directive applies) | ||||||||
Cloudflare Edge | 60 | ||||||||
Other CDN | 200 |
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark