> For the complete documentation index, see [llms.txt](https://docs.tumbler.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tumbler.app/after-first-launch/caching-and-304.md).

# Caching and 304

## Who this is for

Teams that tune subscription performance and want to reduce origin load.

## What you can do

* Enable conditional requests and save traffic.
* Configure correct `Cache-Control`, `ETag`, and `Last-Modified` headers.
* Define the `version_id` update policy.

## Examples

* `ETag: "v2025-01-15T12:00:00Z"`
* `Cache-Control: public, max-age=300`
* `304 Not Modified` response when `If-None-Match` matches.

## See also

* [subscription/response-formats.md](/subscription-contract/response-formats.md)
* [subscription/examples.md](/subscription-contract/examples.md)
* [operations/reliability-and-timeouts.md](/after-first-launch/reliability-and-timeouts.md)

## Header recommendations

* Set `Cache-Control` with public max-age if the response is stable.
* Generate a strong `ETag` from the body or `version_id`.
* Support `If-None-Match` and return `304` without a body.
* Alternative: `Last-Modified` + `If-Modified-Since` if `ETag` is not used.

## ETag and Last-Modified

* ETag must be deterministic: compute it from the canonical response body/`version_id` (normalized JSON with fixed field and node order, no random spaces), not from request time. Same content means same `ETag`.
* Node order matters: clients may choose the first suitable node or cache nodes in received order, so reordering elements is a new version. Change `version_id`/`ETag` to clear caches with stale order even if field values are identical.
* For mirrors and CDNs, return the same `ETag` for the same content to avoid extra downloads.
* `Last-Modified` is optional. Set the actual data modification time (not request time) and update it together with `ETag`.

## 304 response

* When `If-None-Match` is present, compare it with the current `ETag`. If it matches, return `304 Not Modified` without a body.
* If you use `Last-Modified`, check `If-Modified-Since` and also return `304` when content has not changed.
* In a `304` response, repeat current `Cache-Control` and `ETag` (if used) so the cache policy remains known.
* If the original `200` had `Last-Modified`, include it in `304`; if you do not use this header, omit it.

## Update policy

* Change `version_id` and `ETag` for any meaningful content change.
* Do not change `ETag` for decorative edits; only payload changes should affect it.
* When adding/removing/reordering nodes, create a new version: old clients get 200 with the new body, and clients that already cached data get 304 only after `version_id` is updated.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tumbler.app/after-first-launch/caching-and-304.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
