Caching
Validators and conditional requests
Revalidate stale responses with ETag or Last-Modified and understand why a 304 response can save a full body download.
8 minute lesson
~~~
When a cached response becomes stale, the client can ask whether it changed.
An ETag identifies a version of a representation:
ETag: "article-v5"
The next request can include:
If-None-Match: "article-v5"
If the representation is unchanged, the server returns 304 Not Modified without the full body. The client reuses its stored copy.
Last-Modified and If-Modified-Since perform a similar check using a timestamp. ETags can be more precise because the server controls how versions are identified.
Freshness avoids a network request. Validation still contacts the server, but can avoid transferring and parsing the body.
Lesson completed