Toolstia / Cache-Control header builder

Cache-Control header builder

Cache-Control decides how long browsers and CDNs may reuse a response. Pick a preset or set your own values, and copy the header or the matching nginx and Apache line.

Fresh for 1 year.

Cache-Control tells browsers and CDNs how long they may reuse a response. A long max-age with immutable suits files whose names change when their content changes, such as app.3f9a1c.js.

How it works

  1. Choose a preset that matches your file type.
  2. Adjust max-age, shared cache time and the options you need.
  3. Copy the header, the nginx line or the Apache line.

Common presets

Hashed static files can be cached for a year with immutable. HTML pages usually use no-cache so the browser always checks for a new version. Private pages use private so shared caches skip them.

no-cache or no-store

No-cache means the cache may keep the file but must check with the server first. No-store means it must not keep a copy at all, which is for sensitive data.

stale-while-revalidate

This lets a cache show an old copy at once while it fetches a fresh one in the background, which makes pages feel fast.

Warnings

The tool points out combinations that contradict each other, such as no-store with a long max-age.

Questions

Is anything sent to a server?

Everything happens in your browser, and nothing you enter is sent anywhere.

What is s-maxage?

It is the lifetime for shared caches such as a CDN. It overrides max-age there, while browsers still follow max-age.

What does immutable do?

It tells the browser not to recheck the file while it is fresh, even on a reload. Use it only for files whose name changes when the content changes.