What are conditional requests, and how do Last-Modified and If-Modified-Since headers work together?
Last updated
Conditional requests let a client act only if a resource changed (or didn't), saving bandwidth and avoiding lost updates.
The server sends a
Last-Modifiedtimestamp. The client echoes it inIf-Modified-Since, and gets304 Not Modified(no body) if unchanged or200 OKwith the new body if changed.ETag/If-None-Matchis more precise (content hash, not timestamp) andIf-Matchenables optimistic concurrency on writes.
- https://www.youtube.com/watch?v=umBMs-m0JMw
- https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_rest_conditional_requests.htm
- https://zuplo.com/learning-center/optimizing-rest-apis-with-conditional-requests-and-etags
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Conditional_requests