Skip to Content
CoworkingView Docs
Public API

Caching

How to cache CoworkingView API responses: ETag, If-None-Match, 304 and the advisory lifetime of each endpoint.

Catalogue data changes slowly, so caching is the best thing you can do for your app's speed and for staying inside the rate limit.

What the API sends

Every successful GET carries:

  • ETag: a weak validator of the body (it looks like W/"…").
  • Cache-Control: public, max-age=N, stale-while-revalidate=M (or no-store for the few endpoints that must never be reused).

max-age is how long a copy is fresh. stale-while-revalidate is how long beyond that you may keep serving the old copy while you fetch a new one in the background.

Revalidate with If-None-Match

When a copy is no longer fresh, don't download it again blindly. Send the ETag you stored back in If-None-Match:

Your app
API
  1. 1.GET /v1/facets?locale=en
  2. 2.200 · body · ETag: W/"abc" · max-age=600
  3. 3.Store body + ETag
  4. 4.GET … · If-None-Match: W/"abc"
  5. 5.304 Not Modified · no body
  6. 6.Keep using the stored body
If nothing changed you get an empty 304 instead of the full body.
Revalidate from the terminal
curl -i "https://api.coworkingview.com/v1/facets?locale=en" -H 'If-None-Match: W/"abc"'

On 304 the response has no body: keep using the copy you stored, and update its freshness from the new Cache-Control. A 200 means the data changed: replace your copy and its ETag.

How long each endpoint can be reused

These are the advisory lifetimes the API sends today. Always read the real Cache-Control header, as the values can be tuned.

Endpointsmax-agestale-while-revalidate
/v1/properties, /v1/properties/map, /v1/properties/{slug}, /v1/search/suggest5 minutes1 hour
/v1/facets, /v1/market/rates, /v1/operators/{slug}, /v1/places/{kind}/{slug}10 minutes1 hour
/v1/geo/bootstrap (countries, cities, zones)1 hour1 day
/v1/health, and the POST lead endpointsnever cached (no-store)none

/v1/geo/bootstrap changes rarely and is small: fetch it once at start-up and keep it.

Good habits

  • Key your cache by the full URL, including the query string: the same path with another locale or filter is another resource.
  • Don't cache error responses for long. A 429 or a 502 is a moment, not a fact.
  • The meta.citation.accessed date tells you when the data was served; show it if you display figures.
  • If you run a server, put a shared cache in front of the API: many of your users then cost us one request.

On this page