Consider two GET endpoints. One returns a public list of office locations. The other returns the current employee’s expense report. The method is the same. Only the first response is an immediate candidate for reuse between unrelated callers.

Write the sharing contract

For the office directory, list inputs that change its output. Country, language and API version may matter. If an API key grants access to additional locations, keep that representation isolated and verify authorization for each request. Begin with an explicit allowlist of public routes and avoid caching personalized responses.

Preserve meaningful variants

Read the directory through the delivery hostname using two supported languages, then repeat in reverse order. Compare full response bodies and media types. Add a tracking parameter known to have no application meaning and check whether it needlessly creates a new variant. A higher hit rate is valuable only if callers get the right representation.

Define how corrections propagate

Decide how long a closed office may remain visible after an edit. Use origin cache directives or a documented edge policy that satisfies that interval, with a targeted invalidation path for urgent corrections. Test empty responses and upstream errors separately so a transient failure does not become the apparent directory.

Sources & further reading

Reader questions

Can we cache a public response when the request carries credentials?

That requires explicit HTTP shared-cache permission where applicable and a design that cannot disclose caller-specific data. A dedicated anonymous public endpoint is often easier to reason about.