Card 10/ 11
Practice: Caching Headers for Five Endpoints
A product list, a user's profile, an exchange rate, a password reset and an editable document.
Choosing caching headers means asking who may store each response, for how long, and whether writes need a version check. For each endpoint, choose the response headers and say why.
GET /products, public, changes a few times a day.GET /me, the signed-in user's profile.GET /rates/EUR-USD, an exchange rate updated every minute.POST /password-resets, which returns a one-time reset token.GET /documents/9, a document several users edit with PUT.
Show the answers
| Endpoint | Headers | Why |
|---|---|---|
| GET /products | Cache-Control: public, max-age=600, and an ETag | Shared caches may hold it; ten minutes stale is acceptable |
| GET /me | Cache-Control: private, no-cache, and an ETag | Only the user's browser may keep it, and it is checked each use |
| GET /rates/EUR-USD | Cache-Control: max-age=30 | Short freshness absorbs bursts without serving minute-old rates |
| POST /password-resets | Cache-Control: no-store | A secret must never be kept by any cache |
| GET /documents/9 | Cache-Control: private, no-cache, and a strong ETag | Revalidated reads, and the ETag goes back in If-Match on each PUT |
For the document, the server also answers a PUT with no If-Match with 428 Precondition Required, and a stale one with 412.
← → move through sections and cards