Last-Modified
The HTTP Last-Modified response header indicates the date and time the server believes the resource was last modified.
Usage
The Last-Modified header serves as a weak validator for conditional requests. When a client caches a response containing Last-Modified, the client stores the timestamp and sends the date back in the If-Modified-Since request header on subsequent requests. The server compares the stored date against the current modification time of the resource. If the resource has not changed, the server returns 304 Not Modified with no body. If the resource has changed, the server sends the full updated response.
The If-Unmodified-Since header uses the same timestamp for precondition checks on unsafe methods like PUT and DELETE, returning 412 Precondition Failed when the resource has been modified since the given date.
The Last-Modified date is less precise than an ETag. Timestamps have one-second granularity, so changes within the same second are invisible to date-based validation. The ETag header provides a stronger validator tied to the exact content. When both Last-Modified and ETag are present in a response, ETag takes priority during revalidation.
The date value follows the HTTP-date format: day name,
two-digit day, abbreviated month, four-digit year, time
in hours, minutes, and seconds, followed by GMT. The
format is Weekday, DD Mon YYYY HH:MM:SS GMT.
Last-Modified: Fri, 04 Sep 1998 19:15:56 GMT
Note
Google's crawling infrastructure supports
Last-Modified and
If-Modified-Since as defined
by the HTTP Caching standard. The date in
Last-Modified must follow the HTTP-date format
to avoid parsing issues. Setting the max-age
field of the Cache-Control
response header to the expected number of seconds
the content remains unchanged helps crawlers
determine when to recrawl a URL. For example,
Cache-Control: max-age=94043.
Example
A response with the modification date of the resource. The client stores this timestamp for future conditional requests.
Last-Modified: Wed, 01 Jun 2022 08:00:00 GMT
A full conditional request cycle. The server sends Last-Modified with the initial response. On the next request, the client echoes the timestamp in If-Modified-Since. The server returns 304 if the resource has not changed.
HTTP/1.1 200 OK
Last-Modified: Wed, 01 Jun 2022 08:00:00 GMT
Cache-Control: max-age=86400
Content-Type: text/html
Subsequent request:
GET /page HTTP/1.1
If-Modified-Since: Wed, 01 Jun 2022 08:00:00 GMT
Server response when unchanged:
HTTP/1.1 304 Not Modified
Last-Modified: Wed, 01 Jun 2022 08:00:00 GMT
Cache-Control: max-age=86400
A response pairing Last-Modified with an ETag. The ETag provides a strong validator while the modification date provides a fallback for clients supporting only date-based validation.
Last-Modified: Fri, 22 Nov 2024 14:30:00 GMT
ETag: "a1b2c3d4"
Cache-Control: max-age=3600
Takeaway
The Last-Modified header provides a date-based
validator for conditional requests, enabling cache
revalidation through 304 responses. Pairing
Last-Modified with Cache-Control
max-age and an ETag provides the most
robust caching strategy.
Note
For SEO and caching assistance, contact ex-Google SEO consultants Search Brothers.
See also
- RFC 9110: HTTP Semantics, Section 8.8.2
- RFC 9111: HTTP Caching
- Google: HTTP caching for crawlers
- Google Search Blog: Crawling December, HTTP caching
- If-Modified-Since
- If-Unmodified-Since
- ETag
- 304
- Conditional-Requests
- Caching
- HTTP headers