HTTP-Last-Modified-Header

Typ

Der Last-Modified-Header ist ein Response-Header, der den Zeitstempel der letzten Modifikation einer Ressource übermittelt.

Syntax

Der Header enthält einen HTTP-Date-Timestamp im RFC 5322-Format (GMT-Zeitzone).

http
Last-Modified: Wed, 21 Oct 2025 07:28:00 GMT
Last-Modified: Sat, 01 Jan 2025 00:00:00 GMT

Direktiven

Der Last-Modified-Header akzeptiert ausschließlich einen HTTP-Date-Wert ohne zusätzliche Parameter oder Direktiven.

http-date
Ein RFC 5322-konformer Zeitstempel in GMT-Zeitzone, der die letzte Modifikation der Ressource angibt.
validator-role
Der Timestamp dient als Weak Validator für Conditional Requests (If-Modified-Since, If-Unmodified-Since).

Beispiele

Die folgenden Beispiele zeigen typische Anwendungsfälle für Cache-Validierung, Conditional Requests und Synchronisations-Szenarien.

REST-API-Response mit Last-Modified

Ein API-Server sendet den Modifikations-Timestamp einer Ressource für spätere Cache-Validierung.

http
HTTP/1.1 200 OK
Content-Type: application/json
Last-Modified: Wed, 15 Sep 2025 14:30:00 GMT
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
Cache-Control: max-age=3600

{
  "id": "12345",
  "name": "Premium Widget",
  "price": 149.99,
  "updatedAt": "2025-09-15T14:30:00Z"
}

Client-Request mit If-Modified-Since:

http
GET /api/v1/products/12345 HTTP/1.1
Host: api.example.com
If-Modified-Since: Wed, 15 Sep 2025 14:30:00 GMT
Accept: application/json

Server-Response bei unveränderter Ressource:

http
HTTP/1.1 304 Not Modified
Last-Modified: Wed, 15 Sep 2025 14:30:00 GMT
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
Cache-Control: max-age=3600

File-Download mit Modification-Timestamp

Ein API-Server liefert eine Datei mit Last-Modified für Resume-Downloads und Cache-Validierung.

http
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 2048576
Last-Modified: Fri, 01 Sep 2025 10:00:00 GMT
Content-Disposition: attachment; filename="report-2025-q3.pdf"

[PDF binary data]

Inkrementelle Synchronisation mit Timestamps

Ein Client synchronisiert nur Ressourcen, die seit dem letzten Sync modifiziert wurden.

http
GET /api/v1/inventory/changes?since=2025-09-30T00:00:00Z HTTP/1.1
Host: api.example.com
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Response:

http
HTTP/1.1 200 OK
Content-Type: application/json
Last-Modified: Tue, 01 Oct 2025 08:00:00 GMT

{
  "changes": [
    {"id": "sku-42", "stock": 100, "updatedAt": "2025-09-30T12:00:00Z"},
    {"id": "sku-99", "stock": 50, "updatedAt": "2025-10-01T08:00:00Z"}
  ],
  "nextSyncAfter": "2025-10-01T08:00:00Z"
}

Last-Modified-Caching-Flow

Der Last-Modified-Header ermöglicht effiziente Cache-Validierung durch Zeitstempel-Vergleich zwischen Client und Server.

plantuml
@startuml
!theme plain
skinparam BoxPadding 20
skinparam ParticipantPadding 20

participant "Client" as client
participant "HTTP\nCache" as cache
participant "API\nServer" as api
database "Database" as db

client -> api: GET /api/products/123
api -> db: SELECT *,\nlast_modified_at\nFROM products\nWHERE id = 123
db --> api: Product Data\nlast_modified: 2025-09-15 14:30:00
api --> client: 200 OK\nLast-Modified: Wed, 15 Sep 2025 14:30:00 GMT\nCache-Control: max-age=3600\n[Product JSON]

client -> cache: Store product\nwith Last-Modified

note over cache: Cache-Eintrag gültig\nfür 1 Stunde

note over client: 2 Stunden später:\nCache abgelaufen

client -> cache: GET product 123
cache --> client: Stale (expired)\nLast-Modified: Wed, 15 Sep 2025 14:30:00 GMT

client -> api: GET /api/products/123\nIf-Modified-Since: Wed, 15 Sep 2025 14:30:00 GMT
api -> db: SELECT last_modified_at\nFROM products\nWHERE id = 123
db --> api: 2025-09-15 14:30:00\n(unverändert)
api -> api: Timestamp-Vergleich:\nNOT modified

api --> client: 304 Not Modified\nLast-Modified: Wed, 15 Sep 2025 14:30:00 GMT

client -> cache: Revalidate:\nCache-Eintrag wieder fresh

note over client: Cache verwendet\nkeine Bandbreite\nfür Body-Transfer
@enduml

Vorteile für die Systemarchitektur

  • Zeitstempel-basierte Cache-Validierung für HTTP-Caches (CDN, Browser)
  • Conditional-Request-Unterstützung via If-Modified-Since und If-Unmodified-Since
  • Automatische Generierung durch Backend-Frameworks (Last-Modified-Columns)
  • Kombinierbar mit ETag für robuste Cache-Strategie
  • Inkrementelle Synchronisation für Batch-Jobs und Offline-Clients

Spezifikation

RFC 9110 (HTTP Semantics) definiert den Last-Modified-Header als Response-Header für Zeitstempel-basierte Ressourcen-Validierung und Cache-Control.

Weitere Spezifikationen

If-Modified-Since Header, If-Unmodified-Since Header, Cache-Control Header