How do ETag and caching work?
Try code in the playgroundUnderstand the concept
HTTP caching reuses a stored response when its cache rules allow it, reducing repeated work and data transfer. An ETag identifies a resource representation so the client can ask whether its saved version is still valid. Conditional requests allow the server to say “unchanged” without sending the full representation again.
Important ideas
-
An ETag identifies a version of a resource.
-
The client sends
If-None-Match; the server can return304if unchanged. -
Use cache rules carefully so private responses do not reach other users.
-
Cache-Control: no-cachepermits storage but requires validation;no-storeasks caches not to store the response.
Can you explain it without the notes?
How do ETag and caching work?
Use your own words. Explain an example and one limitation before checking the explanation.
Check your explanation
HTTP caching reuses a stored response when its cache rules allow it, reducing repeated work and data transfer. An ETag identifies a resource representation so the client can ask whether its saved version is still valid. Conditional requests allow the server to say “unchanged” without sending the full representation again.
Turn this concept into a clear answer.
- Decide freshness and privacy separately; a fast cache that leaks another user's response is incorrect.
Adapted from 02_NODE_EXPRESS_HTTP.md · “How do ETag and caching work?”. Examples are study fragments; framework behavior can depend on your version.