diff --git a/src/content/docs/cache/concepts/cache-control.mdx b/src/content/docs/cache/concepts/cache-control.mdx index 404fbbf61b30f7..4bc283042f2fa6 100644 --- a/src/content/docs/cache/concepts/cache-control.mdx +++ b/src/content/docs/cache/concepts/cache-control.mdx @@ -101,130 +101,19 @@ The following section covers the directives and behavioral conditions associated 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. -
+| 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=` | Will not cache. | Caches if headers mentioned in `no-cache=` do not exist. Always revalidates if any header mentioned in `no-cache=` is present.| +| `Private=` | Will not cache. | Does not cache `` values mentioned in `Private=` 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. | Wil not cache. | ### Conditions diff --git a/src/content/docs/cache/concepts/cdn-cache-control.mdx b/src/content/docs/cache/concepts/cdn-cache-control.mdx index 857e2f22c73a5f..bbfc694662469b 100644 --- a/src/content/docs/cache/concepts/cdn-cache-control.mdx +++ b/src/content/docs/cache/concepts/cdn-cache-control.mdx @@ -149,3 +149,22 @@ Behavior in response to 5XX error: + +## 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](https://developer.mozilla.org/en-US/docs/Glossary/bfcache) (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-store` disables 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. + +For more information about how these directives behave when Origin Cache Control is enabled or disabled refer to the [Directives](/cache/concepts/cache-control/#directives) section.