Skip to Content

Caching with ETag

How long answers may be kept, and how to ask whether they changed.

Every successful JSON, JSON-LD or GeoJSON answer to your key carries an ETag and Cache-Control: private, max-age=60. The ETag is computed from the body and your key, so it changes whenever anything in the answer changes, and it never matches another key's answer. Export files, article HTML and article feeds have validators of their own (Downloading an export file, Articles).

Reference data changes rarely, so its answers may be kept longer: /genres… and /regions… (lists, single records, GeoJSON, /regions/types) carry Cache-Control: private, max-age=86400 (a day). The LeisureIndex figures under /regions (/regions/scores, /regions/compare, /regions/{id}/leisure-index…) are computed and keep max-age=60. To refresh earlier, send the ETag: a 304 costs nothing.

Send it back to ask "has this changed?":

curl -s -i "https://api.cixtra.app/api/v1/events/0b6c2f0e-5a7e-4d3b-9a51-2f0c1d7e4a10?lang=en" \
  -H "X-API-Key: sk_org_your_key" \
  -H 'If-None-Match: "q4Jx2b9mZr1oV0Q3tC6wK8yN5eH7fL2aP9sD4gU1iBc"'

If nothing changed, the answer is 304 Not Modified with no body. A 304 costs no credits (X-Credit-Cost: 0); it still counts toward the per-minute rate limit. Weak validators (W/"…") and * are accepted.

Answers vary by X-API-Key, by Accept on the endpoints that also answer JSON-LD, and by Accept-Language on the endpoints that choose the language from it (Languages); Vary says so, and shared caches must not serve one key's answer to another. Each language has its own ETag, since the body differs. Note that a list without dateFrom starts "today", so its ETag changes at least once a day.