Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 13 additions & 124 deletions src/content/docs/cache/concepts/cache-control.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<table>
<tbody>
<th colspan="5" rowspan="1">
Directive
</th>
<th colspan="5" rowspan="1">
Origin Cache Control disabled behavior
</th>
<th colspan="5" rowspan="1">
Origin Cache Control enabled behavior
</th>
<tr>
<td colspan="5" rowspan="1">
<code>s-maxage=0</code>
</td>
<td colspan="5" rowspan="1">
Will not cache.
</td>
<td colspan="5" rowspan="1">
Caches and always revalidates
</td>
</tr>
<tr>
<td colspan="5" rowspan="1">
<code>max-age=0</code>
</td>
<td colspan="5" rowspan="1">
Will not cache.
</td>
<td colspan="5" rowspan="1">
Caches and always revalidates.
</td>
</tr>
<tr>
<td colspan="5" rowspan="1">
<code>no-cache</code>
</td>
<td colspan="5" rowspan="1">
Will not cache.
</td>
<td colspan="5" rowspan="1">
Caches and always revalidates. Does not serve stale.
</td>
</tr>
<tr>
<td colspan="5" rowspan="1">
<code>no-cache=&lt;headers&gt;</code>
</td>
<td colspan="5" rowspan="1">
Will not cache.
</td>
<td colspan="5" rowspan="1">
Caches if headers mentioned in <code>no-cache=&lt;headers&gt;</code> do not exist. Always
revalidates if any header mentioned in <code>no-cache=&lt;headers&gt;</code> is present.
</td>
</tr>
<tr>
<td colspan="5" rowspan="1">
<code>Private=&lt;headers&gt;</code>
</td>
<td colspan="5" rowspan="1">
Will not cache.
</td>
<td colspan="5" rowspan="1">
Does not cache <code>&lt;headers&gt;</code> values mentioned in <code>Private=&lt;headers&gt;</code> directive.
</td>
</tr>
<tr>
<td colspan="5" rowspan="1">
<code>must-revalidate</code>
</td>
<td colspan="5" rowspan="1">
Cache directive is ignored and stale is served.
</td>
<td colspan="5" rowspan="1">
Does not serve stale. Must revalidate for CDN and for browser.
</td>
</tr>
<tr>
<td colspan="5" rowspan="1">
<code>proxy-revalidate</code>
</td>
<td colspan="5" rowspan="1">
Cache directive is ignored and stale is served.
</td>
<td colspan="5" rowspan="1">
Does not serve stale. Must revalidate for CDN but not for browser.
</td>
</tr>
<tr>
<td colspan="5" rowspan="1">
<code>no-transform</code>
</td>
<td colspan="5" rowspan="1">
May (un)Gzip, Polish, email filter, etc.
</td>
<td colspan="5" rowspan="1">
Does not transform body.
</td>
</tr>
<tr>
<td colspan="5" rowspan="1">
<code>s-maxage=delta, delta>1</code>
</td>
<td colspan="5" rowspan="1">
Same as <code>max-age</code>.
</td>
<td colspan="5" rowspan="1">
<code>Max-age</code> and <code>proxy-revalidate</code>.
</td>
</tr>
<tr>
<td colspan="5" rowspan="1">
<code>immutable</code>
</td>
<td colspan="5" rowspan="1">
Not proxied downstream.
</td>
<td colspan="5" rowspan="1">
Proxied downstream. Browser facing, does not impact caching proxies.
</td>
</tr>
</tbody>
</table>
| 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. | Wil not cache. |

### Conditions

Expand Down
19 changes: 19 additions & 0 deletions src/content/docs/cache/concepts/cdn-cache-control.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,22 @@ Behavior in response to 5XX error:
</tr>
</tbody>
</table>

## 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.