Free Developer Tool

Generate HTTPCache-Control Headers

Configure Cache-Control headers for HTML pages, JS/CSS bundles, images, fonts, and API responses. Get the exact directive string plus a plain-English breakdown of what each setting does.

Resource Presets

Start from a sensible baseline for HTML, CSS/JS, images, fonts, or API responses — then fine-tune.

🔍

Plain-English Explanations

Every directive gets a clear explanation of what it does and how browsers and CDNs interpret it.

📋

Server Config Examples

Get ready-to-paste Nginx and Apache configuration snippets alongside the header string.

1. Select Resource Type

HTML documents — usually stale-while-revalidate with short or zero max-age

2. Configure Directives

Any cache (browser, CDN, proxy) may store this response.

0 seconds
1m
1d

3. Your Cache-Control Header

Header Value
Cache-Control: public, max-age=0, stale-while-revalidate=60, stale-if-error=86400, must-revalidate
Full Header Line
Cache-Control: public, max-age=0, stale-while-revalidate=60, stale-if-error=86400, must-revalidate

Plain-English Explanation

  • 🌍 public — Any cache (browser, CDN, proxy) may store this response.
  • ⏱️ max-age=0 — The response expires immediately. Must revalidate on every request.
  • ⚡ stale-while-revalidate=60 (1m) — After max-age expires, the browser can serve the stale cached response immediately while fetching a fresh copy in the background. This eliminates latency for the user.
  • 🛡️ stale-if-error=86400 (1d) — If the origin server returns a 5xx error, the stale cached response can be used for up to this long. Protects users during outages.
  • ⚠️ must-revalidate — Once the response is stale, the browser must revalidate with the server before serving it. It cannot use a stale copy even if the server is unreachable.
Nginx
location ~* \.(js|css)$ {
  add_header Cache-Control "public, max-age=0, stale-while-revalidate=60, stale-if-error=86400, must-revalidate";
}
Apache
<FilesMatch "\.(js|css|png|jpg|woff2)$">
  Header set Cache-Control "public, max-age=0, stale-while-revalidate=60, stale-if-error=86400, must-revalidate"
</FilesMatch>

Frequently Asked Questions

Everything you need to know about HTTP Cache Headers Generator.