Caching
ETags, conditional requests and 304.
Data API responses carry a weak ETag (W/"…") and Cache-Control: private, max-age=3600. Other
responses, errors included, carry Cache-Control: no-store.
max-age=3600 lets a client or proxy cache that honours it reuse its copy for up to an hour without
asking the API. To check for a change before that, send the request with Cache-Control: no-cache (or
drop the cached copy) and use If-None-Match as below.
Conditional requests
Repeat a request with If-None-Match: <etag>. While the data is unchanged the API answers
304 Not Modified with an empty body: use your cached copy.
curl -i "https://api.sandbox.bemyplan.com/data/v1/airports?iataCode=AMS" \
-H "Authorization: Bearer bmp_test_…"
# ETag: W/"…"
curl -i "https://api.sandbox.bemyplan.com/data/v1/airports?iataCode=AMS" \
-H "Authorization: Bearer bmp_test_…" \
-H 'If-None-Match: W/"…"'
# HTTP/1.1 304 Not ModifiedWhat to know
- A
304still needs a valid key, counts against your rate limits and appears in your usage, and costs nothing. - The ETag changes when BeMyPlan updates the dataset behind the route (updates are infrequent) or
changes the format of the response. The API reflects a change within about 30 seconds; a client that
honours
max-agemay keep using its cached copy for up to an hour. It differs per route and per query string. - A request that is invalid answers
400, never304. privatemeans that cached copies belong to your account: keep them per account and never put responses in a shared cache.- If a price is set for the call and your balance is zero, a conditional request is refused with
402before it could become a free304. See Credits.