How do ETag and caching work?
Practice this questionWANT TO UNDERSTAND THE CONCEPT FIRST?Learn How do ETag and caching work?
Definition:
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.
Key points:
-
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.
Interview point:
- 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?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.