caching
Last-Modified
Timestamp of when the origin server believes the resource was last modified, used as a weak validator for conditional requests. Clients echo it back in If-Modified-Since to receive a 304 when unchanged.
Last-Modified: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT (IMF-fixdate, RFC 9110) Common directives / values
| Directive | Purpose |
|---|---|
| IMF-fixdate | Preferred format: 'Tue, 15 Nov 1994 12:45:26 GMT' — always GMT, always this shape. |
| rfc850-date | Legacy accepted format: 'Tuesday, 15-Nov-94 12:45:26 GMT'. |
| asctime-date | Legacy accepted format: 'Tue Nov 15 12:45:26 1994'. |
Examples
Last-Modified: Wed, 21 Oct 2025 07:28:00 GMT Standard IMF-fixdate; browser echoes this back as If-Modified-Since on refresh.
Last-Modified: Wed, 21 Oct 2025 07:28:00 GMT\nETag: "abc123" Send both — ETag takes precedence but Last-Modified is a fallback for older caches.
HTTP/1.1 304 Not Modified\nLast-Modified: Wed, 21 Oct 2025 07:28:00 GMT Returned when If-Modified-Since matches; body is omitted.
Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT Epoch trick to force revalidation on caches that only compare timestamps.
Gotcha
Only 1-second resolution — resources modified twice in the same second may serve stale. The date MUST be GMT and formatted exactly per RFC 9110; localized month/day names are non-conforming.
Related headers
If-None-Match
Request header that makes the request conditional: the server returns 200 with the body only if none of the listed ETags match the current representation, otherwise 304 Not Modified. In write requests it protects against creating a duplicate resource.
ETag
An opaque identifier for a specific version of a resource, used by clients in conditional requests to avoid re-downloading unchanged bodies. The server compares the ETag against If-None-Match (or If-Match) and returns 304 Not Modified when they match.
Cache-Control
Directs caching behavior in both requests and responses per RFC 9111, controlling freshness, revalidation, and where the response may be stored. Directives can be combined and are respected by browsers, CDNs, and intermediate proxies.
Vary
Tells caches which request headers were used for content negotiation, so they know to store and serve separate variants keyed by those headers. Missing or wrong Vary causes users to see cached content meant for someone else (wrong language, encoding, or device).