HTTP Cache Header Builder
Generate the correct Cache-Control headers, ETag strategy, and service worker cache strategy for any resource type. Get ready-to-paste Nginx and Apache config snippets.
Resource & Strategy
Generated Headers
Why This Configuration
Server Config Snippet
Frequently Asked Questions
What does 'immutable' mean in Cache-Control?▼
The `immutable` directive tells browsers that the response body will never change during its freshness lifetime. This prevents browsers from sending conditional revalidation requests (If-None-Match / If-Modified-Since) even when the user manually refreshes. Use it only for content-hashed assets like `bundle.a3f7c2.js` where the filename changes when content changes.
When should I use stale-while-revalidate?▼
stale-while-revalidate allows browsers to serve a cached (stale) response immediately while fetching a fresh version in the background. It's ideal for API responses and pages where slight staleness is acceptable but you want near-instant loads. Example: `Cache-Control: max-age=60, stale-while-revalidate=3600` — serve from cache for 1 min, then background-revalidate for up to 1 hour.
What is the Vary header used for?▼
The `Vary` header tells caches which request headers affect the response content. For example, `Vary: Accept-Encoding` means the cache must store separate versions for gzip and non-gzip clients. `Vary: Accept-Language` stores language-specific versions. Misconfiguring Vary can cause cache thrashing (too many variants) or serving wrong content to users.
Should I use ETags with hashed filenames?▼
No — if your filenames include a content hash (like bundle.a3f7c2.js), the URL itself changes when content changes. ETags provide no additional benefit and add unnecessary server overhead for revalidation requests. ETags are most valuable for content without cache-busting URLs, like HTML pages, API responses, or image files with stable names.
What is the difference between Cache-First and Network-First service worker strategies?▼
Cache-First serves from cache immediately, falling back to network if not cached — best for static assets that rarely change. Network-First always tries the network first and falls back to cache on failure — best for dynamic content where freshness matters. Stale-While-Revalidate serves cached content immediately and updates the cache in the background — best for frequently updated but non-critical content.
Related Products
on GumroadDeveloper 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 →AI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →Developer Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad →You Might Also Need
nginx Config Generator
Generate production-ready nginx server blocks instantly. Supports static sites, reverse proxy (Node.js, API), PHP-FPM, and HTTPS redirects. Includes SSL/TLS, gzip, cache headers, security headers, and
Open free tool →
nginx Config Builder
Build nginx server blocks and location blocks with a visual form. Configure reverse proxy, static file serving, WebSocket, CORS, gzip, and security headers. Generates copy-ready nginx config snippets.
Open free tool →
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 →
More Free Tools
Related Articles
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.
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.
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.
Nginx Configuration Guide for Web Developers 2026: Reverse Proxy, SSL & Performance
Master Nginx configuration in 2026. Complete guide covering reverse proxy setup, SSL/TLS with Let's Encrypt, gzip compression, caching, rate limiting, load balancing, and common gotchas.
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.
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 →