What is the If-Unmodified-Since header?
The If-Unmodified-Since request header, defined in RFC 9110 Section 13.1.4, makes a request conditional on the selected representation’s last modification date being earlier than or equal to the date the client sends. It is the date-based counterpart of If-Match: the client echoes back the Last-Modified value it last saw, and the server refuses to apply the change if the resource has moved on since.
API Usage & Best Practices
- Prevent lost updates without ETags: Send it on
PUT,PATCHandDELETEwhen the resource exposesLast-Modifiedbut noETag. If the condition is false, the server must not perform the method and typically answers412 Precondition Failed. - Prefer If-Match when you can: A recipient must ignore
If-Unmodified-Sincewhen the request also carriesIf-Match. HTTP dates have one-second resolution, so two writes inside the same second are indistinguishable by date; an entity tag has no such blind spot. If you control the API, emit ETags and useIf-Unmodified-Sinceonly as a fallback. - Send the server’s own value back verbatim: The timestamp is interpreted against the origin server’s clock, so copy
Last-Modifiedfrom the earlier response rather than generating a date from the client’s clock. - Invalid dates are ignored, not rejected: The server must ignore the header if the value is not a valid HTTP-date or if the resource has no modification date. That silently turns a conditional write into an unconditional one. If your API requires conditional writes, enforce it explicitly and return
428 Precondition Requiredwhen no usable precondition is present. - Not for refreshing a partial download: On a range request, use
If-Rangeif you want the full new representation when the resource has changed, instead of a412.
Examples
A client updates a document using the Last-Modified value from its earlier GET:
PUT /v1/documents/doc_42 HTTP/1.1Host: api.example.comContent-Type: application/jsonIf-Unmodified-Since: Tue, 07 Jul 2026 10:00:00 GMT
{"title": "Q3 plan", "status": "draft"}Someone else changed the document after that time, so the write is refused:
HTTP/1.1 412 Precondition FailedContent-Type: application/problem+jsonLast-Modified: Tue, 07 Jul 2026 10:04:12 GMT