HTTP Cache Header Generator
Generate correct Cache-Control headers (max-age, s-maxage, public/private, immutable, must-revalidate, stale-while-revalidate) with ETag and Last-Modified validators. Includes nginx config snippets and presets for static assets, APIs, and SPAs. 100% client-side.
Loading tool...
What is HTTP Cache Header Generator?
The HTTP Cache Header Generator produces correct Cache-Control, ETag, and Last-Modified headers for the most common web workloads: long-lived static assets, short-lived API responses, SPA HTML entry points, and immutable CDN content. Choose a preset and fine-tune max-age, s-maxage, public/private, immutable, must-revalidate, and stale-while-revalidate, and the tool writes the full header set plus a matching nginx config snippet. Everything is generated client-side, so your domains and paths never leave the browser.
Key Benefits
- Avoid hand-writing Cache-Control syntax and the typos that cause stale content or unnecessary revalidation
- Four battle-tested presets cover static assets, API responses, SPA HTML, and immutable CDN content
- ETag and Last-Modified validators enable efficient 304 Not Modified conditional requests that save bandwidth
- A matching nginx config snippet is generated so you can deploy the same caching strategy to your server
- 100% client-side generation β no domains, paths, or configuration details are ever uploaded
Common Use Cases
- β’Caching build-hashed static assets (JS, CSS, images, fonts) for a year with immutable
- β’Configuring short-lived or no-cache headers for API JSON responses that change frequently
- β’Setting up SPA HTML entry points that revalidate on every load while hashed assets cache forever
- β’Tuning CDN cache behavior with s-maxage and stale-while-revalidate to reduce origin load
- β’Quickly producing a correct caching baseline for a new domain, staging environment, or nginx server block
How to Use the HTTP Cache Header Generator
- Pick a preset: Choose Static Assets, API Response, SPA / HTML, or Immutable CDN. The controls update to match the selected workload automatically.
- Tune max-age and s-maxage: Set the browser cache lifetime (max-age) and the shared/CDN cache lifetime (s-maxage) in seconds. Duration hints show the equivalent in days, hours, or minutes.
- Toggle validators and directives: Enable ETag, Last-Modified, public/private, immutable, must-revalidate, and stale-while-revalidate as needed for your workload.
- Copy the headers or nginx snippet: Review the generated HTTP headers and nginx config snippet, then copy them to your clipboard or download the headers as a .txt file.
Key Features
- Four production presets: static assets, API response, SPA HTML, and immutable CDN content
- Full Cache-Control builder: max-age, s-maxage, public/private, immutable, must-revalidate, stale-while-revalidate
- ETag and Last-Modified conditional validators that enable efficient 304 Not Modified responses
- Auto-generated nginx config snippet matched to the selected preset, ready to paste into your server block
- Human-readable duration hints (days/hours/minutes) next to each max-age and s-maxage input
- Copy to clipboard and download as .txt β fully offline, no API keys, no network calls