Skip to main content

What each response allows

private means shared caches, such as a corporate proxy or a CDN, must not store the response: it was produced for your key. For records, the most reliable cache is your own store, updated from the changes feed or by polling ids in batches. HTTP caching helps when you re-read individual records.

Conditional requests

Retrieve returns a weak ETag, a hash of the response body:
Send it back in If-None-Match. If the record has not changed, the answer is 304 Not Modified with no body, repeating ETag, Cache-Control and Vary:
A 304 is still a counted call, but it carries no body, so it is faster and lighter for both sides. The ETag changes whenever any part of the response changes, including updated_at, so a register reload invalidates every ETag in that register even when nothing visible changed. ETags depend on the exact request. A retrieve with include=goods_services has a different ETag from the same record without it; keep one cache entry per URL.

Compression

Responses of 1 KB or more are compressed with gzip when the request allows it. Send Accept-Encoding: gzip: most HTTP libraries do this by default, and with cURL use --compressed. Search and batch responses compress well, often to a fifth of their size.

Don’t cache errors

Error responses are no-store. A 503 or 429 says something about this moment; retry it as described in Handling errors, and never serve a cached error to your own users.