Node.jsInterview preparation
Foundation·Concept·2 min read

How do ETag and caching work?

Practice this question

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 return 304 if unchanged.

  • Use cache rules carefully so private responses do not reach other users.

  • Cache-Control: no-cache permits storage but requires validation; no-store asks 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.