LESSON 10 / 22·2 min readFoundation

How do ETag and caching work?

Try code in the playground
01 Understand02 Recall03 Prepare

Understand 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 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.

PAUSE & RECALL

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.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

  • Decide freshness and privacy separately; a fast cache that leaks another user's response is incorrect.
Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: How should pagination and API versioning work?

Adapted from 02_NODE_EXPRESS_HTTP.md · “How do ETag and caching work?”. Examples are study fragments; framework behavior can depend on your version.