Dung (Donny) Nguyen

Senior Software Engineer

Last-Modified Header

The Last-Modified header is an HTTP response header that indicates the date and time at which the resource was last modified on the server. It is used by clients (like web browsers) to determine whether they need to fetch a fresh copy of the resource or if they can use a cached version.

Here’s how it works:

  1. Client sends a request: When a client requests a resource from a server, it includes the If-Modified-Since header in the request, if it has a cached version of the resource. This header contains the timestamp of the last time the client fetched the resource.
  2. Server checks Last-Modified: The server compares the If-Modified-Since header in the request with the Last-Modified header of the resource.
  3. Server responds:
    • If the Last-Modified header of the resource is later than the If-Modified-Since header in the request, it means the resource has been modified since the last time the client fetched it. The server sends a 200 OK response with the updated resource.
    • If the Last-Modified header of the resource is the same or earlier than the If-Modified-Since header in the request, it means the resource has not been modified since the last time the client fetched it. The server sends a 304 Not Modified response, indicating that the client can use its cached copy of the resource.

Benefits of using Last-Modified header:

Note: