Skip to main content
KalkuNet

Cache-Control Header Generator — Get Browser and CDN Caching Right

Configure public/private, max-age, s-maxage & stale-while-revalidate directives.

Runs in your browserWeb · HTTP, URLs & Redirects
Presets:
Who may store it:
Output format:
  • public — may be stored by browsers and shared caches (CDN, proxy)
  • max-age=300 — fresh in the browser for 5 minutes
  • s-maxage=86400 — fresh in CDNs/proxies for 1 day (overrides max-age for shared caches)
  • stale-while-revalidate=60 — after expiry, the old copy may be served for 1 minute while it refreshes in the background
  • stale-if-error=86400 — if the server errors, the old copy may be served for up to 1 day

When to use the HTTP Cache-Control & CDN TTL Header Builder

  • Separate browser and CDN lifetimes

    max-age sets how long browsers keep a response and s-maxage how long a CDN or proxy such as Cloudflare keeps it, so pages refresh quickly at the edge without slowing visitors down.

  • Common presets

    Hashed static assets are kept for a year with immutable, HTML pages always revalidate, account data is never stored, and the CDN pattern uses stale-while-revalidate.

  • Contradictions flagged

    Combinations that cancel each other out, such as no-store with max-age or private with s-maxage, are flagged straight away with an explanation.

  • Ready for your server

    The result is available as a raw header, Nginx config, an Apache .htaccess, Caddy, or a _headers file for Cloudflare Pages and Netlify.

Frequently asked questions

What is the difference between no-cache and no-store?

no-cache may be stored but must be revalidated with the server before use; no-store must not be stored at all. For pages that change often, no-cache is usually enough.

Does Cloudflare honour s-maxage?

Yes. When caching follows the origin's headers, Cloudflare uses s-maxage for the edge lifetime and max-age for browsers. Cache rules in the dashboard can override that.

What does stale-while-revalidate do?

After a response expires, a cache may serve the old copy while it fetches a new one in the background, so visitors do not wait.

Where do I put this header?

In your server or CDN configuration: a location block in Nginx, an .htaccess file in Apache, a Caddyfile or a _headers file. Pick the format above and download it.

Learn more