Generate correct Cache-Control headers for any resource type. Configure max-age, stale-while-revalidate, immutable, and more — and get the exact header string plus a plain-English explanation of every directive.

HTTP Cache Headers Generator is a free, browser-based developer tool that helps you configure correct Cache-Control headers for any resource type — HTML pages, JavaScript and CSS bundles, images, web fonts, and API responses. Select a resource type preset, fine-tune the directives with toggles and number inputs, and copy the finished header string along with ready-to-paste Nginx and Apache configuration snippets.
HTTP caching is one of the highest-leverage performance optimisations available on the web. A one-year max-age with immutable on hashed assets means returning visitors never re-download the same file. Correct stale-while-revalidate on HTML means pages load instantly even after content updates. But getting the directive combination exactly right is error-prone.
Most developers copy header values from Stack Overflow answers or documentation snippets written for different use cases. The wrong directive — say, setting no-cache when you meant no-store, or adding immutable to an unhashed filename — causes subtle, hard-to-debug cache poisoning or unnecessary revalidation overhead.
There was no quick, interactive tool for generating correct Cache-Control headers with plain-English explanations alongside the output. This is that tool.
Six presets cover the most common resource types:
public, max-age=0, must-revalidate, stale-while-revalidate=60 — expires immediately but allows 60 seconds of background revalidation so users never wait on a round-trip.public, max-age=31536000, immutable — one-year cache, never revalidated, because the content hash in the filename guarantees uniqueness.public, max-age=2592000, stale-while-revalidate=86400 — 30-day cache with a one-day background refresh window.public, max-age=31536000, immutable — fonts rarely change; treat them like hashed assets.private, max-age=0, must-revalidate — responses go to one user only; CDNs must not store them.Each preset sets sensible defaults and explains why they make sense for that resource type.
Adjust any directive after selecting a preset:
public, private, no-cache, no-store2592000 → 30d)max-age, leaving browser caching unchangedmax-age; use only with content-hashed filenamesThe output panel shows:
public, max-age=31536000, immutableCache-Control: public, max-age=31536000, immutablelocation block.htaccess snippet using Header setOne click copies any of the four outputs to clipboard.
public, private, no-cache, no-store, max-age, s-maxage, stale-while-revalidate, stale-if-error, immutable, must-revalidate86400 displays as 1d, 3600 as 1hThe tool is a single client-side component with no external API calls. State is managed with useState; the header string and explanations are derived values computed on every render. Preset application replaces the full config object, ensuring consistency without imperative setter calls.
The explanation engine maps each active directive to a plain-English string with the formatted duration injected. The Nginx and Apache snippets are template strings that reference the live header value, so they update in real time as directives change.
Setting cache headers correctly is one of the first steps in a Core Web Vitals audit. Use the CSS/JS preset as a starting point for hashed static assets, then copy the Nginx snippet directly into your server config.
When configuring a CDN origin policy or reviewing cache rules in a reverse proxy, use the tool to prototype the header string before applying it. The s-maxage option is particularly useful for CDN-specific policies that differ from browser cache behaviour.
REST APIs often need different cache policies per endpoint — private for user-specific data, public with a short max-age for shared read endpoints. Use the API preset as a base and adjust per route.
When onboarding engineers to a project's caching strategy, use the tool's plain-English explanations to communicate why a particular header combination was chosen without expecting them to read the RFC.
2592000 means nothing; 30d is obviousstale-while-revalidate that Stack Overflow answers often omitTry it now: http-cache-headers-generator.tools.jagodana.com
The client needed a robust developer tools solution that could scale with their growing user base while maintaining a seamless user experience across all devices.
We built a modern application using HTTP and Caching, focusing on performance, accessibility, and a delightful user experience.
Category
Developer Tools
Technologies
Date
April 2026
More work in Developer Tools