HTTP Cache-Control Builder
Build the right Cache-Control header for any resource type.
Choose your caching strategy — HTML pages, hashed JS/CSS, API responses, images — and get the complete directive string
with plain-English explanations for every directive included.
Frequently Asked Questions
What is the Cache-Control header and what directives can it contain?▼
Cache-Control is an HTTP header that controls how browsers, CDNs, and proxies cache responses. Key directives: max-age=N (cache for N seconds), s-maxage=N (CDN-only override for max-age), no-cache (cache but revalidate every request), no-store (never cache), private (browser only, no CDN), public (shareable caches allowed), immutable (file won't change — skip revalidation), must-revalidate (don't use stale content), stale-while-revalidate=N (serve stale for N seconds while fetching fresh in background).
What is the difference between no-cache and no-store?▼
no-cache means 'cache the response, but always revalidate before using it.' The browser stores the response and sends a conditional request (If-None-Match or If-Modified-Since). If the server returns 304 Not Modified, the cached version is used at zero data transfer cost. no-store means 'never save this response anywhere.' Every request fetches a completely fresh copy. Use no-store for sensitive data (bank statements, private health records). Use no-cache for HTML pages that need to stay fresh but can benefit from 304 conditional requests.
When should I use the immutable directive?▼
Use immutable for assets with content-hashed URLs like bundle.a3f9c1.js or styles.8e7d2b.css. These files never change at a given URL — the filename changes when content changes. immutable tells browsers to never revalidate even on reload (Ctrl+F5). Combined with max-age=31536000 (1 year), this eliminates all network requests for cached assets on repeat visits, dramatically improving performance.
What is stale-while-revalidate and how does it improve performance?▼
stale-while-revalidate=N allows serving a stale (expired) cached response for N seconds while fetching a fresh copy in the background. This eliminates the latency spike that occurs when a cache entry expires — users always get an instant response, and the cache is updated asynchronously. Pattern: Cache-Control: max-age=60, stale-while-revalidate=300 — serve fresh for 60 seconds, serve stale for 5 more minutes while refreshing. Widely supported in modern browsers and CDNs like Cloudflare.
What is the difference between private and public?▼
public means the response can be stored by any cache — browser, CDN, or intermediary proxy. Use this for static assets that are the same for all users. private means only the user's own browser can cache it — CDNs must not store it. Use private for authenticated responses that contain user-specific data. If you omit both, the cache behavior is heuristic-based and inconsistent across implementations — always set one explicitly.
How do ETags work with Cache-Control?▼
An ETag is a fingerprint of the response content (usually a hash or timestamp). When a cached response expires, the browser sends the ETag in an If-None-Match request header. If the content hasn't changed, the server responds with 304 Not Modified and no body — saving bandwidth. ETags work alongside Cache-Control: no-cache for HTML pages: the page is always revalidated, but if nothing changed, the revalidation costs only a round trip with no data transfer.
Related Products
on GumroadDevToolkit Starter Kit
A ready-to-deploy developer tools website with 12 built-in tools. Astro + Preact + Tailwind. Deploy to Cloudflare Pages for free. Built-in SEO, dark mode, and ad-ready layout.
Buy on Gumroad →TypeScript Quick Reference Toolkit
5 practical reference files for TypeScript developers: cheatsheet, TS vs JS comparison, 20 utility types with real examples, tsconfig best practices template, and 15 common mistakes guide. Print it. Keep it on your desk.
Buy on Gumroad →Developer Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →You Might Also Need
HTTP Status Code Reference
Complete HTTP status code reference. Search all 1xx, 2xx, 3xx, 4xx, and 5xx codes with plain-English descriptions, real-world use cases, and when to use each in REST APIs.
Open free tool →
LLM Prompt Caching Calculator
Calculate cost savings from LLM prompt caching. Compare Anthropic Claude and OpenAI GPT-4 caching pricing. Estimate monthly savings based on call volume and cache hit rate.
Open free tool →
HTTP Status Code Reference
Complete HTTP status code reference. Look up all 1xx, 2xx, 3xx, 4xx, and 5xx codes with plain-English descriptions, real-world use cases, and when to use each. Searchable and filterable.
Open free tool →
More Free Tools
Related Articles
CDN and Edge Caching 2026: Complete Guide to Content Delivery Networks and Edge Computing
Comprehensive guide to CDN and edge caching strategies for 2026. Covers Cloudflare, Fastly, Akamai, AWS CloudFront, edge functions, cache invalidation, real-time synchronization, and multi-CDN strategies with code examples.
Performance Optimization 2026: Complete Guide to Frontend, Backend, and Infrastructure
Comprehensive performance optimization guide for 2026 covering Core Web Vitals, JavaScript bundle optimization, server-side rendering, caching strategies, database query optimization, CDN configuration, and real-world benchmarks.
Caching Strategies for Web Developers: Browser, CDN, Server-Side, and Database
Complete guide to web caching strategies. Covers HTTP cache headers, CDN configuration, Redis/Memcached patterns, service workers, and database query caching with practical code examples and performance benchmarks.
HTTP Headers Explained: Security & Performance (2025)
A developer's guide to HTTP headers. Covers security headers (HSTS, CSP, CORS), performance headers (Cache-Control, ETag), and how to inspect headers with free tools.
Redis Caching Patterns for Node.js Applications
Master Redis caching in Node.js with practical patterns: cache-aside, write-through, cache invalidation, TTL strategies, pub/sub, and production-ready implementation with ioredis.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →