[ADP-134] Last-Modified
Overview
The Last-Modified header is an important HTTP response header that indicates the date and time at which the origin server believes the resource was last modified.
Purpose
The main purposes of the Last-Modified header are:
- To enable caching mechanisms in browsers and proxy servers.
- To support conditional requests, allowing clients to check if a resource has been modified since their last retrieval.
Guidance
- Servers MUST include the
Last-Modifiedheader for cacheable resources whenever possible. - The
Last-Modifieddate SHOULD be as accurate as possible. - If the last modification time cannot be determined, servers SHOULD NOT send a
Last-Modifiedheader. - Clients SHOULD use the
If-Modified-Sinceheader in conjunction withLast-Modifiedfor efficient caching. - For frequently changing resources, consider using the
ETagheader as an alternative or supplement. - For dynamically generated content, use
Last-Modifiedcautiously, ensuring its accuracy.
Usage
Server Response
When responding to a GET or HEAD request, a server should include the Last-Modified header if it can determine the last modification time of the requested resource.
Example:
http
HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Wed, 21 Oct 2023 07:28:00 GMTClient Request
Clients can use the If-Modified-Since header in subsequent requests to check if the resource has been modified since their last retrieval.
Example:
http
GET /example.html HTTP/1.1
Host: www.example.com
If-Modified-Since: Wed, 21 Oct 2023 07:28:00 GMTRelated Headers
ETag: Provides a more precise mechanism for validating cached resources.If-Modified-Since: Used in client requests to conditionally retrieve resources.Cache-Control: Specifies directives for caching mechanisms in both requests and responses.