A client sends If-None-Match: "abc123" and the resource is unchanged. Server response?
Options
- 200 OK with the full body of the resource
- 304 Not Modified with no body (Correct option)
- 204 No Content with no body
- 412 Precondition Failed with an error
Answer
304 Not Modified with no body
Why
An ETag is a version fingerprint the server sends with a response. The client stores it.
Next time, the client sends If-None-Match: <etag>. If nothing changed, the server answers 304 Not Modified with an empty body, and the client reuses its cached copy. This saves bandwidth.
For updates, If-Match prevents overwriting someone else's change (412 if the version is old).
Remember
Same ETag → 304, reuse the cache.