Skip to content
Astera Technology

Validate cached API data with a resource version

Match a validator to the stored representation before reusing a 304 response.

Keep data and validator together

HTTP supports ETag and conditional reads. A 304 response is not a fresh replacement body. The sample values below are synthetic opaque tags; do not strip quotes or infer a business revision by parsing them.

Synthetic cache validation trace
Stored stateRequest/responseHandling
Body A plus ETag "v-a"If-None-Match: "v-a" → 304Reuse matching stored A under cache rules
Body A plus ETag "v-a"200 with body B and "v-b"Replace body and validator together
Validator present, body missing304 receivedRecover with a full authorised read
Download editable CSV ↓

Invalidate after the relevant write

Decide which representations a write affects: a record view, list membership and derived totals may all differ. Standard HTTP cache behaviour does not automatically invalidate every application-side derived cache. Test an edit followed by detail and list reads.

Can the client display an empty object after 304 when the original body was evicted?

Show the worked answer

No. The validator alone is not the representation. Perform a supported full read and restore a consistent data/validator pair.

Related resources