Ch. 20 · Networking

HTTP Cache-Control and Response Freshness

HTTP Cache-Control and Response Freshness. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readintermediateupdated Oct 3, 2026

Cache directives describe storage and reuse rules. Public sharing, private caches and revalidation are separate decisions.

Before you start

You should understand clients, servers, IP addresses and ports. Follow a request through name resolution, connection establishment and application exchange. Distinguish protocol guarantees from deployment policy, and use observations from the relevant layer rather than guessing from one browser error message.

The practical goal is to reason through this situation: A personalized response must not accidentally enter a shared cache under a generic key. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.

Step-by-step walkthrough

Step 1: Decide storage sensitivity

Private information may need stricter storage rules than public assets.

Step 2: Separate storage and freshness

No-cache requires validation before reuse; no-store addresses storage.

Step 3: Inspect shared intermediaries

A browser test alone does not establish CDN behavior.

Worked scenario

A personalized response must not accidentally enter a shared cache under a generic key.

A response with no-cache may be retained but must be revalidated according to applicable semantics before reuse. Sensitive account data can need no-store under its policy. Public responses also require a cache key and variation rules that preserve correctness; similarly named directives solve different parts of the problem.

Common mistake

No-cache means revalidate before reuse, not necessarily do not store.

Verify the behavior

Test browser and intermediary reuse, including authenticated responses and changed content.

Interview exercise

Protect sensitive responses.

Answer and reasoning

Choose storage policy from the data’s sensitivity and deployment, and verify intermediary behavior instead of relying on a name’s intuition.

Continue learning

Compare the scenario with the Networking interview questions and test your understanding with the Networking MCQs. For terminology and implementation details, consult the reference material.

More in Networking

read ✓Networking · mid

Networking: HTTP Redirects

Choose between 301, 302, 307 and 308, know which preserve the request method, and avoid caching and loop mistakes.

~2 min readread →
read ✓Networking · mid

HTTP Cookies, Scope and Browser Delivery

HTTP Cookies, Scope and Browser Delivery. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readread →
read ✓Networking · easy

HTTP Methods, Safety and Idempotence

HTTP Methods, Safety and Idempotence. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readread →
esc