Origin Cache Control
Last updated Jun 30, 2026
Origin Cache Control is a Cloudflare feature. When enabled on an Enterprise customer's website, it indicates that Cloudflare should strictly respect Cache-Control directives received from the origin server. Free, Pro and Business customers have this feature enabled by default.
Cache-Control directives in the HTTP response from your origin server provide specific caching instructions ↗︎ to intermediary services like Cloudflare.
With the Origin Cache Control feature enabled, Cache-Control directives present in the origin server's response will be followed as specified. For example, if the response includes a max-age directive of 3,600 seconds, Cloudflare will cache the resource for that duration before checking the origin server again for updates.
Cloudflare's Cache Rules allows users to either augment or override an origin server's Cache-Control headers or default policies set by Cloudflare.
The following sections cover:
- The most common
Cache-Controldirectives. - How to enable Origin Cache Control.
- How Origin Cache Control behaves with
Cache-Controldirectives. - How other Cloudflare products interact with
Cache-Controldirectives.
Cache-control directives
A Cache-Control header can include a number of directives, and the directive dictates who can cache a resource along with how long those resources can be cached before they must be updated.
Note
For more information about Cache-Control directives at origin servers, refer to the Mozilla Cache-Control documentation ↗︎.
If multiple directives are passed together, each directive is separated by a comma. If the directive takes an argument, it follows the directive separated by an equal sign. For example: max-age=86400.
Directives can be broken down into four groups: cacheability, expiration, revalidation, and other.
Cacheability
Cacheability refers to whether or not a resource should enter a cache, and the directives below indicate a resource's cacheability.
public— Indicates any cache may store the response, even if the response is normally non-cacheable or cacheable only within a private cache.private— Indicates the response message is intended for a single user, such as a browser cache, and must not be stored by a shared cache like Cloudflare or a corporate proxy.no-store— Indicates any cache, such as a client or proxy cache, must not store any part of either the immediate request or response.
Expiration
Expiration refers to how long a resource should remain in the cache, and the directives below affect how long a resource stays in the cache.
Note
Cloudflare respects whichever value is higher: the Browser Cache TTL in Cloudflare or the max-age header. You can also simultaneously specify a Cloudflare Edge Cache TTL different than a Browser's Cache TTL respectively via the s-maxage and max-age Cache-Control headers.
When using Origin Cache Control and setting max-age=0, Cloudflare prefers to cache and revalidate. With Origin Cache Control off and max-age=0, Cloudflare will bypass cache.
When setting no-cache with Origin Cache Control off, Cloudflare does not cache. When setting no-cache with Origin Cache Control on, Cloudflare caches and always revalidates.
max-age=seconds— Indicates the response is stale after its age is greater than the specified number of seconds. Age is defined as the time in seconds since the asset was served from the origin server. Thesecondsargument is an unquoted integer.s-maxage=seconds— Indicates that in shared caches, the maximum age specified by this directive overrides the maximum age specified by either themax-agedirective or theExpiresheader field. Thes-maxagedirective also implies the semantics of theproxy-revalidateresponse directive. Browsers ignores-maxage.
`s-maxage` disables `stale-while-revalidate`
Per RFC 9111 ↗︎, s-maxage incorporates the semantics of proxy-revalidate, which means a shared cache must not serve stale content without first revalidating with the origin. For a complete list of directives that disable stale-while-revalidate and workarounds, refer to Controlling stale behavior.
no-cache— Indicates the response cannot be used to satisfy a subsequent request without successful validation on the origin server. This allows an origin server to prevent a cache from using the origin to satisfy a request without contacting it, even by caches that have been configured to send stale responses.
Ensure the HTTP Expires header is set in your origin server to use Greenwich Mean Time (GMT) as stipulated in RFC 2616 ↗︎.
Revalidation
Revalidation determines how the cache should behave when a resource expires, and the directives below affect the revalidation behavior.
must-revalidate— Indicates that once the resource is stale, a cache (client or proxy) must not use the response to satisfy subsequent requests without successful validation on the origin server.proxy-revalidate— Has the same meaning as themust-revalidateresponse directive except that it does not apply to private client caches.stale-while-revalidate=<seconds>— When present in an HTTP response, indicates caches may serve the response in which it appears after it becomes stale, up to the indicated number of seconds since the resource expired. If Always Online is enabled, then thestale-while-revalidateandstale-if-errordirectives are ignored. This directive is not supported when using the Cache API methodscache.matchorcache.put. For more information, refer to the Workers documentation for Cache API.
Note
stale-while-revalidate is now fully asynchronous. The first request after expiry triggers revalidation in the background and immediately receives stale content with an UPDATING status instead of blocking. All requests during revalidation are served stale with an UPDATING status until the origin responds, after which they receive a HIT.
For more details, refer to Revalidation.
stale-if-error=<seconds>— Indicates that when an error is encountered, a cached stale response may be used to satisfy the request, regardless of other freshness information. To avoid this behavior, includestale-if-error=0directive with the object returned from the origin. This directive is not supported when using the Cache API methodscache.matchorcache.put. For more information, refer to the Workers documentation for Cache API.
Error status codes
The stale-if-error directive triggers when your origin returns a 5xx status code (500, 502, 503, 504). Other responses such as 404 are not considered errors for this purpose — the origin response replaces the stale cached content. There is currently no way to customize which status codes trigger stale-if-error.
The stale-if-error directive is ignored if Always Online is enabled or if an explicit in-protocol directive is passed. Examples of explicit in-protocol directives include a no-store or no-cache cache directive, a must-revalidate cache-response-directive, or an applicable s-maxage or proxy-revalidate cache-response-directive.
Other
Additional directives that influence cache behavior are listed below.
no-transform— Indicates that an intermediary — regardless of whether it implements a cache — must not transform the payload.vary— By default, Cloudflare does not consider vary values in caching decisions. Vary values are respected when you configure the Cache Rules Vary setting, when Vary for images is configured, and when the vary header isvary: accept-encoding.immutable— Indicates to clients the response body does not change over time. The resource, if unexpired, is unchanged on the server. The user should not send a conditional revalidation request, such asIf-None-MatchorIf-Modified-Since, to check for updates, even when the user explicitly refreshes the page. This directive has no effect on public caches like Cloudflare, but does change browser behavior.
Understand no-store and no-cache directives
There is often confusion between the directives Cache-Control: no-store and Cache-Control: no-cache, particularly regarding how they impact browser caching and features like the Back-Forward Cache ↗︎ (BFCache).
no-store
- Tells both browsers and intermediaries (like CDNs) not to store a copy of the response under any circumstance.
- The response is never written to disk or memory, which means the browser must fetch it again every time.
- In many browsers,
no-storedisables BFCache, because restoring a page from BFCache requires the browser to keep a copy of the page's memory state, which contradicts the “do not store” directive. - This directive is used for highly sensitive or dynamic data (for example, banking apps, personal information, secure dashboards).
no-cache
- Allows storing of the response (in both browser and intermediate caches), but requires revalidation with the origin server before using it.
- This ensures the content is always up-to-date, while still potentially allowing BFCache or other forms of performance optimization.
- This directive is used for data that changes frequently but is not sensitive, and can be served faster if validated rather than re-downloaded.
