Origin Cache Control·续
For more information about how these directives behave when Origin Cache Control is enabled or disabled refer to the Directives section.
Enable Origin Cache Control
If you enable Origin Cache Control, Cloudflare will aim to strictly adhere to RFC 7234 ↗︎. Enterprise customers have the ability to select if Cloudflare will adhere to this behavior, enabling or disabling Origin Cache Control for their websites through cache rules in the dashboard or via API. Free, Pro, and Business customers have this option enabled by default and cannot disable it.
Origin Cache Control behavior
The following section covers the directives and behavioral conditions associated with enabling or disabling Origin Cache Control.
Integer values required
The max-age, s-maxage, and stale-while-revalidate directives require integer values per RFC 9111. Floating-point values (for example, max-age=2.5) are not valid and will be ignored, potentially causing cache bypass. Ensure your origin returns integer TTL values.
Directives
The table below lists directives and their behaviors when Origin Cache Control is disabled and when it is enabled.
| Directive | Origin Cache Control Disabled Behavior | Origin Cache Control Enabled Behavior |
|---|---|---|
s-maxage=0 |
Will not cache. | Caches and always revalidates |
max-age=0 |
Will not cache. | Caches and always revalidates. |
no-cache |
Will not cache. | Caches and always revalidates. Does not serve stale. |
no-cache=<headers> |
Will not cache. | Caches if headers mentioned in no-cache=<headers> do not exist. Always revalidates if any header mentioned in no-cache=<headers> is present. |
Private=<headers> |
Will not cache. | Does not cache <headers> values mentioned in Private=<headers> directive. |
must-revalidate |
Cache directive is ignored and stale is served. | Does not serve stale. Must revalidate for CDN and for browser. |
proxy-revalidate |
Cache directive is ignored and stale is served. | Does not serve stale. Must revalidate for CDN but not for browser. |
no-transform |
May (un)Gzip, Polish, email filter, etc. | Does not transform body. |
s-maxage=delta, delta>1 |
Same as max-age. |
Max-age and proxy-revalidate. |
immutable |
Not proxied downstream. | Proxied downstream. Browser facing, does not impact caching proxies. |
no-store |
Will not cache. | Will not cache. |
Conditions
Certain scenarios also affect Origin Cache Control behavior when it is enabled or disabled.
Condition | | | | | Origin Cache Control disabled behavior | | | | | Origin Cache Control enabled behavior | | | |
Presence of Authorization header. |
Content may be cached. | Content is cached only if must-revalidate, public, or s-maxage is also present. |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Use of no-cache header. |
In logs, cacheStatus=miss. |
In logs, cacheStatus=bypass. |
||||||||||||
Origin response has Set-Cookie header and default cache level is used. |
Content may be cached with stripped set-cookie header. |
Content is not cached. | ||||||||||||
| Browser Cache TTL is set. | Cache-Control returned to eyeball does not include private. |
If origin returns private in Cache-Control then preserve it. |
Note
When the Cloudflare-Cdn-Cache-Control header is set, OCC is turned on (regardless of whether OCC is enabled or disabled). As a result, we apply our Authorization header logic (per RFC 7234, Section 3.2 ↗︎) to allow only the s-maxage, must-revalidate, or public directives. If any other directive is present, we do not cache the asset and instead return BYPASS.
Examples
Review the examples below to learn which directives to use with the Cache-Control header to control specific caching behavior.
<details>
<summary>
Cache a static asset.
</summary>
<code>Cache-Control: public, max-age=86400</code>
</details>
<details>
<summary>
Ensure a secret asset is never cached.
</summary>
<code>Cache-Control: no-store</code>
</details>
<details>
<summary>
Cache assets on browsers but not on proxy cache.
</summary>
<code>Cache-Control: private, max-age=3600</code>
</details>
<details>
<summary>
Cache assets in client and proxy caches, but prefer revalidation when serve.
</summary>
<code>Cache-Control: public, no-cache</code>
</details>
<details>
<summary>
Cache assets in proxy caches but REQUIRE revalidation by the proxy when serve.
</summary>
<code>Cache-Control: public, no-cache, proxy-revalidate</code> or <code>Cache-Control: public, s-maxage=0</code>
</details>
<details>
<summary>
Cache assets in proxy caches, but REQUIRE revalidation by any cache when serve.
</summary>
<code>Cache-Control: public, no-cache, must-revalidate</code>
</details>
<details>
<summary>
Cache assets, but ensure the proxy does not modify it.
</summary>
<code>Cache-Control: public, no-transform</code>
This configuration also disables transformation like gzip or brotli compression from our edge to your visitors if the original payload was served uncompressed.
</details>
<details>
<summary>
Cache assets with revalidation, but allow stale responses if origin server is unreachable.
</summary>
<code>Cache-Control: public, max-age=3600, stale-if-error=60</code>
With this configuration, Cloudflare attempts to revalidate the content with the origin server after it has been in cache for 3600 seconds (one hour). If the server returns an error instead of proper revalidation responses, Cloudflare continues serving the stale resource for a total of one minute beyond the expiration of the resource.
</details>
<details>
<summary>
Cache assets for different amounts of time on Cloudflare and in visitor browsers.
</summary>
<code>Cache-Control: public, max-age=7200, s-maxage=3600</code>
</details>
<details>
<summary>
Cache an asset and serve while asset is being revalidated.
</summary>
<code>Cache-Control: max-age=600, stale-while-revalidate=30</code>
This configuration indicates the asset is fresh for 600 seconds. The asset can be served stale for up to an additional 30 seconds while Cloudflare revalidates the asset with the origin in the background. For more information, refer to <a href="https://developers.cloudflare.com/cache/concepts/revalidation/">Revalidation</a>.
Note
Do not use <code>s-maxage</code> with <code>stale-while-revalidate</code>. The <code>s-maxage</code> directive implies <code>proxy-revalidate</code>, which prevents shared caches from serving stale content. For workarounds, refer to <a href="https://developers.cloudflare.com/cache/concepts/revalidation/#controlling-stale-behavior">Controlling stale behavior</a>.
</details>
Interaction with other Cloudflare features
This section covers how other Cloudflare features interact with Cache-Control directives.
Edge Cache TTL
Edge Cache TTL Cache Rules override s-maxage and disable revalidation directives if present. When Origin Cache Control is enabled at Cloudflare, the original Cache-Control header passes downstream from our edge even if Edge Cache TTL overrides are present. Otherwise, when Origin Cache Control is disabled at Cloudflare, Cloudflare overrides the Origin Cache Control.
Browser Cache TTL
Browser Cache TTL Cache Rules override max-age settings passed downstream from our edge, typically to your visitor's browsers.
Polish
Polish is disabled when the no-transform directive is present.
Gzip and Other Compression
Compression is disabled when the no-transform directive is present. If the original asset fetched from the origin is compressed, it is served compressed to the visitor. If the original asset is uncompressed, compression is not applied.
JavaScript Detections
JavaScript Detections injection is disabled when the no-transform directive is present. The cf.bot_management.js_detection.passed field will show as missing for affected requests.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/cache/concepts/cache-control/#page","headline":"Origin Cache Control","description":"How origin Cache-Control headers affect Cloudflare caching behavior.","url":"https://developers.cloudflare.com/cache/concepts/cache-control/","inLanguage":"en","image":"https://developers.cloudflare.com/cache/concepts/cache-control/og.png?v=23af6d3580d01903","dateModified":"2026-06-30","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["Headers"]}
description: Cache status headers returned by Cloudflare in HTTP responses. title: Cloudflare cache responses image: https://developers.cloudflare.com/cache/concepts/cache-responses/og.png?v=52e1af2623eceded
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/cache/llms.txt
Use this file to discover all available pages before exploring further.
Docs