Skip to content
Back to Path
Module 10 of 18

ETag & Last-Modified

Validation headers allow the client to say: "I have an old copy of this file. Has it changed?". This saves bandwidth by not downloading the same data twice.

Interactive Protocol Simulation
Step 1 / 2

Step 1 of 2

GET /image.png
If-None-Match: "v1"
Matches "v1"?
Conditional Request: No data transfer needed!

Worked example

Request

If-None-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"

Response

HTTP/1.1 304 Not Modified

A 304 response is tiny because it contains no body. It simply tells the browser "Your old copy is still perfect, keep using it".

ETag (Entity Tag)

An ETag is a unique fingerprint (hash) of a file. If the file content changes, the fingerprint changes.

The Validation Flow

1. Server sends file with ETag: "v1". 2. Browser saves file and ETag. 3. Next time, Browser sends If-None-Match: "v1". 4. Server compares ETags. If they match, it sends "304 Not Modified" (no body!).

Study kit

Module 10 of 18

Intermediate · 3 min · 0 of 18 complete

Module status

Not completed yet

Notessaved locally+

Notes stay in this browser. They are not uploaded.

Suggest an edit

Discussion

0 comments

Loading discussion…

Sign in to ask a question.