Cachingmedium5-8 years
How do ETags and conditional requests actually save work, and what's the difference between a strong and a weak validator?
A server sends an ETag — an opaque version identifier for a response. The client stores it and, next time, sends If-None-Match: <tag>; if it still matches, the server replies 304 Not Modified with no body at all, and the client reuses what it already has. Whether this saves real server work depends entirely on how the tag is computed: Spring's default ShallowEtagHeaderFilter hashes the rendered response, so the controller still ran and the database still got queried — only the bytes on the wire were saved. To save the work too, the tag has to come from something cheap to check before doing the expensive part, like a version column.