HTTP ETags Explained: Revalidate a Public Course Catalogue
Practical Web Development — Lesson 8 of 10 · Advanced A public course catalogue may change only a few times a day, but visitors can request it repeatedly. HTTP validators let a client ask whether its cached representation is still current. An ETag identifies a version of a representation; a conditional request can avoid downloading the same body again. Follow one revalidation exchange These are illustrative HTTP messages, not JavaScript to paste into Blogger. The server must generate a validator that changes when the selected representation changes. GET /api/courses HTTP/1.1 Host: example.test HTTP/1.1 200 OK Content-Type: application/json Cache-Control: public, max-age=60 ETag: "catalogue-v7" [{"id":"html","title":"HTML fundamentals"}] # After the cached response becomes stale: GET /api/courses HTTP/1.1 Host: example.test If-None-Match: "catalogue-v7" HTTP/1.1 304 Not Modified Cache-Control: public, max-age=60 ETag: ...