Cache-Control Header Generator
Create the right Cache-Control header with presets for static files, HTML pages and private data.
—Correct caching, faster sites
The Cache-Control header decides how long and under what conditions browsers and CDNs may store a response. Correct caching speeds up pages and reduces server load; wrong caching can show users stale content or store private data in shared caches.
Presets
- Versioned static files: long-lived and immutable
- HTML pages: revalidate on every request
- Private or sensitive content: private or no-store
Explained and ready to apply
Every directive (max-age, s-maxage, no-cache, no-store, private, public, immutable, stale-while-revalidate) is explained in plain words. The resulting header is shown with ready snippets for Nginx, Apache and ASP.NET Core.
How to use Cache-Control Header Generator
- Choose the preset for your content type.
- Edit individual directives if needed.
- Read the explanations to confirm the behaviour.
- Copy the snippet for your server.
Why use this tool?
Prevents performance and privacy problems caused by caching mistakes and makes PageSpeed's 'efficient cache policy' advice easy to follow.
FAQ
What's the difference between no-cache and no-store?
no-cache allows storing but requires revalidation before each use; no-store forbids storing the response at all.
When should I use immutable?
For static files whose names contain a version or hash and whose content never changes.
Can I set a separate time for the CDN?
Yes, the s-maxage directive sets a separate lifetime for shared caches such as CDNs.
Related tools
Security Headers Generator
Create CSP, HSTS, Referrer-Policy, Permissions-Policy and other headers for Nginx, Apache, IIS or Netlify.
Open toolNginx Redirect Generator
Create Nginx 301/302 page redirects plus HTTP → HTTPS and www / non-www rules.
Open tool.htaccess Redirect Generator
Create Apache .htaccess page-level 301/302 rules plus HTTP → HTTPS and www / non-www redirects.
Open toolRobots.txt Generator
Create a robots.txt file with Allow, Disallow and sitemap rules for search engine bots.
Open tool