# Caching

> Reuse responses with ETags, and know how fresh each kind of response is.

Public responses are cached at the edge, so most requests are fast. You can
cache them too.

## Revalidate with ETags

Keep each response's `ETag` and send it back as `If-None-Match`, exactly as you
received it (it may be weak, `W/"…"`). An unchanged response answers
`304 Not Modified` with no body: reuse your copy.

| Response                                              | Browser `Cache-Control`               |
| ----------------------------------------------------- | ------------------------------------- |
| Titles, Sets, Boxsets, Loadouts, Assets, YAML         | `public, no-cache`                    |
| Creator profiles and pages, Lists, `/config`          | `public, no-cache`                    |
| Index manifests and chunks, activity feeds            | `public, no-cache`                    |
| Images on `img.mediux.io`                             | `public, max-age=31536000, immutable` |
| Errors and `308` redirects                            | `no-store`                            |
| Protected API                                         | `private, no-store`                   |

`public, no-cache` means you may keep the response but must revalidate it before
reuse. No response is served stale while revalidating.

## How fresh things are

- **Changes to titles, Sets, Assets, Lists and profiles** show up within seconds.
- **Indexes** and **List subscriber counts** refresh hourly.
- **Activity feeds** can be up to an hour behind.
- **Privacy changes**, such as a List made private or an account deleted, take
  effect straight away.
- **Images never change** at a given URL: replaced artwork gets a new ID. That's
  why images can be cached for a year.

Don't cache Protected API responses in a shared cache: they belong to one user.
