HTTP Cache-Control Directives

Cache-Control directives for browser and shared caches, with example values, intended behavior, and common configuration mistakes.

  • JSON5,965 B
  • YAML4,198 B · −30%
  • TOON3,421 B · −43%

Cache-Control directives for browser and shared caches, with example values, intended behavior, and common configuration mistakes. Each row includes a practical application and a failure to check before using it.

Use it when

  • Choose cache policy for an API or a static asset.
  • Debug a response that is stale or revalidated too often.

Watch out for

  • These are response examples; request directives can have different effects.
  • Extensions depend on the cache implementation.

The data

DirectiveExampleUsePitfall
max-agemax-age=300Permit reuse while the response is fresh for 300 seconds.Age already spent in an upstream cache counts toward freshness.
s-maxages-maxage=60Set freshness for shared caches separately from browsers.It does not set a browser-only lifetime.
no-cacheno-cacheStore a response but validate it before reuse.The name does not mean do not store.
no-storeno-storeAsk caches not to retain this request or response.It does not erase copies stored before this response.
privateprivateKeep a personalized response out of shared caches.A browser may still store it.
publicpublic, max-age=600Explicitly permit shared-cache storage under HTTP rules.Do not expose user-specific content.
must-revalidatemust-revalidateRequire validation after freshness expires.It does not force validation while fresh.
proxy-revalidateproxy-revalidateApply the stale-validation requirement to shared caches.Private browser caches are outside this directive.
no-transformno-transformAsk intermediaries to preserve the representation.Compression and media pipelines need their own testing.
immutablepublic, max-age=31536000, immutableAvoid revalidation during freshness for versioned assets.Change the URL when the asset bytes change.
stale-while-revalidatemax-age=60, stale-while-revalidate=30Allow a bounded stale response during background validation.Support and CDN configuration vary.
stale-if-errormax-age=60, stale-if-error=600Allow bounded stale reuse on eligible failures.Not suitable for every correctness-sensitive response.

Fields

The shape of this dataset, read from the data itself: every column, its type and a real value. Agents can use this to plan a query without fetching the whole document.

SectionFieldTypeExample
datadirectivestringmax-age
dataexamplestringmax-age=300
datausestringPermit reuse while the response is fresh for 30…
datapitfallstringAge already spent in an upstream cache counts t…

Fetch the same bytes

The static files contain the same reference rows as the API, with no API rate limit. Live metadata, such as view counts, may differ. Use the API for content negotiation; use the static files for a cacheable snapshot.

curl "https://yjtoon.com/api/dataset/http-cache-directives?format=toon"
const res = await fetch(
  "https://yjtoon.com/static-data/dataset/http-cache-directives.toon"
);
const toon = await res.text();

Rate limit: 120 requests per minute per IP, no key and no signup. API reference →

Sources and editorial notes

Original editorial reference notes by YJTOON, informed by the linked primary documentation. External specifications retain their own licenses.

Editorial review: . Source documents keep their own licenses.

Topics

  • http-status-codes
  • http cache directives
  • reference
  • engineering

Search the library

Search by a topic, title, or keyword.

Start with a collection

Browse all 205 datasets