Skip to content
HTTP

Caching

Cache-Control, ETag, and conditional requests.

#cache#etag#conditional

Code

http
# Response caching headers
HTTP/1.1 200 OK
Cache-Control: public, max-age=3600
ETag: "abc123"
Last-Modified: Wed, 01 Jan 2024 00:00:00 GMT
Vary: Accept-Encoding

---

# Conditional request (revalidation)
GET /api/data HTTP/1.1
Host: example.com
If-None-Match: "abc123"
If-Modified-Since: Wed, 01 Jan 2024 00:00:00 GMT

---

# Response when unchanged
HTTP/1.1 304 Not Modified
ETag: "abc123"