Developer ToolsA little help for every day

Search by name or task, such as JSON or percentage.

Developer Tools

Cache-Control Header Generator

Build Cache-Control, ETag and Last-Modified headers for public, private, no-cache or no-store caching, as raw headers or Nginx, Apache or Express config.

View all tools
ResultUpdates as you type
Cache-Controlpublic, max-age=3600
Cache-Control: public, max-age=3600
DirectiveWhat it does
publicBrowsers and shared caches such as CDNs may store it
max-age=3600Seconds the browser treats the response as fresh

Browsers cache for 1 hour.

How to use Cache-Control Header Generator

Pick a caching strategy, set max-age and any optional directives in seconds, minutes, hours or days, and choose an output format. The header, ready-to-paste config and a table explaining each directive update as you go.

  1. Choose a strategyPublic for static assets and CDNs, Private for personal data, Revalidate each time for HTML, or Never store for sensitive pages.
  2. Set the durationsEnter max-age, plus optional s-maxage, stale-while-revalidate and stale-if-error, in the unit you choose.
  3. Pick an output formatCopy raw headers, Nginx add_header lines, Apache .htaccess, a Cloudflare Pages or Netlify _headers file, or Express code.

Typical Cache-Control settings

For content-hashed JS, CSS and image files, choose Public, set max-age to 365 days and tick immutable: the header becomes public, max-age=31536000, immutable, so browsers do not recheck for a year. HTML pages usually suit no-cache, which allows storage but requires a check with the server before each use, ideally backed by an ETag or Last-Modified value. API responses containing personal data should be private with a short max-age, and password or payment pages no-store. A max-age of 0 is allowed and means every use needs revalidation.

What the other directives do

s-maxage sets the freshness for shared caches such as CDNs and overrides max-age there; it is left out for private responses. stale-while-revalidate lets a cache serve the old copy for a while after expiry while it refreshes in the background, and stale-if-error lets it keep serving the old copy if the origin fails. must-revalidate forbids serving stale content at all. For example, max-age 10, s-maxage 60 and stale-while-revalidate 30, all in minutes, give public, max-age=600, s-maxage=3600, stale-while-revalidate=1800. A last-modified date is converted to the GMT format HTTP requires.

Accuracy and data handling

Validate the result with your project's own tests and runtime rules before using it in production. The calculation runs in your current browser; the tool code does not send the input to a processing API.

Often Used Together

Next step

FAQ

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

no-cache lets browsers and CDNs keep a copy, but they must check with the server before reusing it. no-store forbids keeping a copy at all. Use no-cache when content must be fresh but you still want cheap 304 responses.

What does always mean in the Nginx config?

By default add_header only applies to 2xx and 3xx responses. Adding always makes Nginx send the headers with 4xx and 5xx error responses too.

My caching header has no effect. What should I check?

Confirm in your browser's developer tools that the response really carries the header and that Disable cache is not ticked, then look for CDN rules that override headers from the origin.

More Developer Tools

Related tools