HTTP Cache-Control Builder

Performance

Optimize your website's performance by crafting the perfect caching strategy. Visually configure directives, calculate TTLs, and get real-time header strings for your server configuration.

Boolean Directives

Time Directives (TTL)

max-age (Freshness)
Time the client considers the resource fresh.
3600s
s-maxage (Shared Cache)
Overrides max-age for shared caches (CDNs).
0s
stale-while-revalidate
Continue using stale data while fetching new version in background.
0s
stale-if-error
Use stale data if the server returns an error.
0s

Quick Strategies

Generated Header

Cache-Control: public, max-age=3600
Caching Strategy

A balanced caching policy. Ensure your CDN (s-maxage) matches your deployment invalidation strategy.

Strategic Caching Overview

Freshness (Max-Age)

Calculates how long a resource is considered fresh. Once expired, the browser will attempt to revalidate it with a conditional request.

Visibility (Public vs Private)

`public` allows any cache (including CDNs/Proxies) to store the data. `private` restricts caching to the user's browser only.

Revalidation

Directives like `must-revalidate` ensure that the browser never uses a stale resource without checking the server first if it has expired.

Cache-Control Builder FAQs

The `Cache-Control` HTTP header is used to specify browser and intermediary caching policies. It tells browsers and CDNs whether they can store a resource, for how long, and under what conditions they should revalidate it.

`no-cache` tells the browser it can store the resource but MUST revalidate it with the server before using it. `no-store` tells the browser/CDNs not to store the resource at all, effectively disabling caching for that file.

The `immutable` directive tells the browser that a resource's content will never change while it stays in the cache. This prevents the browser from sending conditional revalidation requests (304 Not Modified) even when the user reloads the page.

For versioned static assets (e.g., `main.a1b2c3.js`), a strong policy like `public, max-age=31536000, immutable` is recommended. This avoids unnecessary network requests for a full year.

Related DevOps

All Tools