Anatomy of Modern Cache-Control Directives
Cache-Control: public, max-age=31536000, immutable instructs browsers and intermediate CDNs to cache hashed static assets (JS chunks, CSS stylesheets) for a full year without ever querying the server again.
For dynamic HTML or API endpoints, stale-while-revalidate=86400 serves cached content instantaneously while asynchronously fetching fresh updates in the background.
ETags and Conditional 304 Handshakes
An Entity Tag (ETag) is a unique cryptographic digest (such as a truncated SHA-256 hash or file modification time) assigned by the server to a specific version of a resource.
When the local browser cache expires, the client sends If-None-Match: "xyz123". If the resource remains unchanged, the server responds with a lightweight HTTP 304 Not Modified header with zero payload body.
Step-by-Step Tutorial
Audit Response Headers in DevTools
Open Chrome DevTools > Network tab. Inspect Cache-Control, Age, ETag, and CF-Cache-Status headers.
Segment Static from Dynamic Routes
Apply 1-year immutable caching to /_next/static/* and strict no-cache, must-revalidate to user-specific API routes.
Validate 304 Not Modified Handshake
Execute curl -I --header 'If-None-Match: "etag-value"' https://yourdomain.com/asset to verify status code 304 response.
Ready to Try It Yourself?
DocSwift processes everything directly on your device. Fast, safe, and completely free forever.
How helpful was this guide?
Rated 4.9 / 5 by 3,420+ users worldwide
Share with Colleagues & Friends
Help others protect their document privacy
Frequently Asked Questions
What is the difference between no-cache and no-store?
no-cache permits browsers to store the file, but forces revalidation with the server before every use. no-store completely forbids saving the file to disk or memory.
Does Cloudflare CDN respect origin Cache-Control headers?
Yes, by default Cloudflare respects origin Cache-Control directives unless overridden by Page Rules or Cache Rules.