browser: can haz foo?
GET /foo HTTP/1.1
server: o hai, dis version 12345.
note, there's always an empty line between headers & body.
HTTP/1.1 200 OK
ETag: "12345"
<!doctype html><p>foo.
browser: hai. can haz latest? i haz 12345.
GET /foo HTTP/1.1
If-None-Match: "12345"
server: u haz latest lol!
HTTP/1.1 304 Not Modified
if page has changed + new version is 56789,
server: lol wut! herez latest
HTTP/1.1 200 OK
ETag: "56789"
<!doctype html><p>new foo.
GET requests with If-None-Match
headers are called conditional GET requests, since the server only returns a response body if there's new content. You can also use date-based validation to issue conditional GETs, saving transfer bandwidth without implementing ETags. The flow is the same, except the server sends down an Expires
date, and the browser sends it back as a Last-Modified
header.
See the HTTP 1.1 RFC for more details. It's more readable than you'd think.
Also, those are valid html5 documents in the examples; I just omitted optional tags.
Maybe server sends
Last-Modified
header, and the browserIf-Modified-Since
?