Quickstart

Quickstart: Cut bandwidth with conditional requests

When the API sends an ETag, a conditional request lets you skip the body entirely if nothing changed — a 304 and no payload. This recipe shows the exact code, uses only the unauthenticated public ring, and links out to the endpoints and the application flow so the reader always has a next step.

2 min read

ETagVersion stamp
If-None-MatchAsk 'changed?'
304Nothing to download

Send the ETag back

etag = cache.get('products_etag')
headers = {'If-None-Match': etag} if etag else {}
r = requests.get(f'{BASE}/products', headers=headers, timeout=10)
if r.status_code == 304:
    return cache.get('products')          # unchanged
r.raise_for_status()
cache.set('products_etag', r.headers.get('ETag'))
cache.set('products', r.json()['data'])

When it helps

Conditional requests shine when you poll reference data that rarely changes. You still make the request, but a 304 skips the body, saving bandwidth and parsing on every unchanged poll.

Frequently asked questions

Do all endpoints send an ETag?

Cacheable reference endpoints do. If no ETag is present, fall back to Cache-Control and a TTL.

Does a 304 count against rate limits?

Treat it like any request. It saves bandwidth, not a request slot, so still cache and avoid tight polling.

Funding for UK limited companies

Credicorp lends to your company, not to you personally — short-term working capital with no personal guarantee. See what your business could access.