Cache-Control Header Explained: How to Check and Set It

The Cache-Control header is the HTTP response header that tells browsers and CDNs whether they may store a file and for how long, for example Cache-Control: public, max-age=31536000 (reuse it without checking for a year). To check it, run curl -sS -o /dev/null -D - https://yoursite.com/ | grep -i cache-control on Mac, Linux or Git Bash. In Windows PowerShell, type curl.exe -sS -o NUL -D - https://yoursite.com/ | findstr /i cache-control. No output means that response has no Cache-Control. Use the final https:// address: my http:// request to this site got a 301 redirect with no Cache-Control.

Below: what each directive means, real headers from this site and four well-known sites (26 November 2026), what to set, and why changes sometimes don’t show.

Title card: Cache-Control header explained, with the example header public, max-age=31536000, immutable

Key takeaways

  • no-cache means “check before reusing”, not “don’t cache”. no-store means don’t keep a copy.
  • Versioned CSS, JS and images can be cached for a year; HTML usually needs no-cache or a short lifetime.
  • This site’s HTML had no Cache-Control; its JS, CSS and images got public, max-age=31557600 (365.25 days).
  • Check with a GET, not only curl -I: Cloudflare’s homepage answered HEAD and GET differently.
  • Lighthouse’s “Serve static assets with an efficient cache policy” is now the “Use efficient cache lifetimes” insight.
Table of Contents
  1. 1What the Cache-Control Header Does
  2. 2Real Cache-Control Headers From Five Sites
  3. 3How to Check Cache-Control
  4. 1. Chrome DevTools
  5. 2. curl on Mac, Linux or Git Bash
  6. 3. Windows PowerShell
  7. 4. Read the CDN and page-cache headers too
  8. 5. Lighthouse
  9. 4What Values to Use
  10. 5How to Set It on Your Platform
  11. 6Why Your Changes Don’t Show
  12. 7Does Cache-Control Help Speed and SEO?
  13. 8Mistakes to Avoid
  14. What does Cache-Control max-age mean?
  15. What is the difference between no-cache and no-store?
  16. What is s-maxage in Cache-Control?
  17. How do I check the Cache-Control header of a website?
  18. How do I fix “Use efficient cache lifetimes” in Lighthouse?
  19. Should HTML pages have a long Cache-Control max-age?

What the Cache-Control Header Does

MDN calls the browser’s own store a “private cache” and a cache in between, such as a proxy or CDN, a “shared cache”. Cache-Control speaks to both. RFC 9111 (June 2022) defines the directives; RFC 5861 adds stale-while-revalidate and RFC 8246 adds immutable.

DirectiveWhat it means
max-age=NFresh for N seconds, counted from when the origin generated it (MDN).
s-maxage=NLike max-age, but only for shared caches (CDNs, proxies).
no-cacheMay be stored, but must be checked with the server before each reuse.
no-storeMust not be stored by any cache.
publicAny cache may store it, even where it would otherwise be blocked.
privateOnly the browser may store it. For logged-in or personal pages.
must-revalidateOnce stale, must be checked with the server before reuse.
immutableWon’t change while fresh, so don’t re-check it on a normal reload.
stale-while-revalidate=NOnce stale, may be served for N more seconds while a fresh copy is fetched in the background.
From RFC 9111, RFC 5861, RFC 8246 and MDN, checked 26 November 2026.

Expires gives a date after which the copy is stale, but RFC 9111 says that with max-age present “a recipient MUST ignore the Expires header field”. Age is a cache’s estimate, in seconds, of how long ago the origin generated or last validated the response. So max-age=3600 with Age: 3148 leaves 452 seconds of freshness (MDN’s homepage, HEAD).

MDN’s compatibility data lists stale-while-revalidate in Chrome 75, Firefox 68 and Safari 14, and immutable in Firefox 49 and Safari 11 but not Chrome. Browsers that don’t know a directive should ignore it.

Diagram: the origin server sends Cache-Control; the CDN, a shared cache, uses s-maxage and the browser, a private cache, uses max-age; no-cache means revalidate and no-store means do not keep

Real Cache-Control Headers From Five Sites

On 26 November 2026 (13:27-13:35 UTC) I requested each homepage plus a static file found in its HTML, with curl’s default user agent from my Windows 11 PC in India, as both HEAD (curl -I) and GET.

ResponseCache-Control (GET)Other cache headers
harshilbarot.com homepage and an articlenoneETag, x-litespeed-cache, x-hcdn-cache-status
harshilbarot.com JS, CSS and logo WebPpublic, max-age=31557600Expires one year and 6 hours later
wordpress.org homepagenonenone
wordpress.org JS and PNGmax-age=315360000 (10 years)Expires 31 Dec 2037: nginx’s expires max pattern
www.cloudflare.com homepagemax-age=10CF-Cache-Status: HIT; HEAD got no-store instead
www.cloudflare.com CSSmax-age=31536000HEAD got public, max-age=31536000, immutable
github.com homepagemax-age=0, private, must-revalidateETag
GitHub asset CSSpublic, max-age=31536000, immutableX-Cache: HIT, HIT; Age 622063
developer.mozilla.org homepagepublic, max-age=3600Age 3149; Expires already in the past
MDN CSSpublic, max-age=31536000Age 1580; Expires already in the past
Real headers from Git Bash curl 8.19.0 and Windows curl.exe 8.23.0, 26 November 2026.
Real Cache-Control headers on 26 November 2026: harshilbarot.com HTML none and static files public max-age 31557600, Cloudflare HTML max-age 10, GitHub HTML private, MDN HTML max-age 3600, wordpress.org static 10 years
Real readings from curl, 26 November 2026.
  • This site’s HTML sends no Cache-Control, only an ETag and the LiteSpeed and Hostinger CDN status headers (wordpress.org’s homepage sent none either). With no lifetime given, RFC 9111 lets a cache use a heuristic, with no fixed algorithm.
  • 31557600 is not a typo. It is 365.25 days, the Browser Cache TTL that LiteSpeed’s docs recommend for the LiteSpeed Cache plugin; I didn’t confirm which layer adds it here. Lighthouse’s example is 31536000 (365 days).
  • HEAD and GET can disagree. Cloudflare’s homepage answered HEAD with no-store in both runs and GET with max-age=10 in all five GET checks; its CSS lost public and immutable on GET. So check with a GET.
  • An old Expires doesn’t matter when max-age is set. MDN’s homepage sent an Expires time over 11 hours in the past, plus max-age=3600, which wins.

How to Check Cache-Control

1. Chrome DevTools

  1. Press F12 (Cmd+Option+I on Mac), open Network, reload.
  2. Click the page or a CSS, JS or image request, open Headers and read cache-control, expires, age and any CDN status header.
  3. Reload with Disable cache unticked: the Size column shows which files came from the browser’s cache.

2. curl on Mac, Linux or Git Bash

curl -sS -o /dev/null -D - https://yoursite.com/ | grep -iE "^(cache-control|expires|age|cf-cache-status|x-litespeed-cache|x-hcdn-cache-status):"

This sends a GET, discards the body and prints the cache headers; -S keeps errors visible. Run it on the page and on one CSS, JS and image URL from your page source. Keep the ^ anchors: in my unanchored test (findstr), age: matched GitHub’s content-language line and expires its Set-Cookie lines; an unanchored grep would match them too.

3. Windows PowerShell

curl.exe -sS -o NUL -D - https://yoursite.com/ | findstr /i /r "^cache-control: ^expires: ^age: ^cf-cache-status: ^x-litespeed-cache: ^x-hcdn-cache-status:"

Type curl.exe, not curl: in Windows PowerShell 5.1, curl is an alias for Invoke-WebRequest. (More on reading headers: checking status codes and headers.)

4. Read the CDN and page-cache headers too

Status headers show what a cache actually did. Cloudflare defines cf-cache-status: HIT as “found in Cloudflare’s cache”; DYNAMIC means not eligible (HTML, by default). x-litespeed-cache comes from LiteSpeed’s page cache (what x-litespeed-cache: miss means), and x-hcdn-cache-status from Hostinger’s CDN on this site. Background: how a CDN caches files.

5. Lighthouse

Chrome’s docs say the old “Serve static assets with an efficient cache policy” audit (uses-long-cache-ttl) was replaced by the use-cache-insight audit, shown as Use efficient cache lifetimes, in Lighthouse 13. It asks for “a cache lifetime of at least 30 days (2592000 seconds)” on fonts, images, media, scripts and style sheets, not the HTML page.

Four ways to check Cache-Control: Chrome DevTools Network headers, curl GET with grep, PowerShell curl.exe with findstr, Lighthouse Use efficient cache lifetimes insight

What Values to Use

ResponseSuggested Cache-ControlWhy
CSS, JS, fonts, images with a version in the URLpublic, max-age=31536000, immutableA new version gets a new URL (public is optional).
Static files whose URL never changesA shorter max-age, such as a weekVisitors keep the old file until it expires.
HTML pagesno-cache, or a short max-ageVisitors get new HTML and the new asset URLs in it (MDN).
Logged-in, cart or account pagesprivate, or no-store for sensitive dataKeeps them out of shared caches.
Based on MDN, RFC 8246 and Chrome’s Lighthouse docs.

Many CSS and JS URLs carry a version string (this site’s JS ends in ?ver=aa5e7); its uploaded logo URL has none. RFC 9111 adds that no-store “is not a reliable or sufficient mechanism for ensuring privacy”. On Cloudflare, don’t pair s-maxage with stale-while-revalidate: its docs say s-maxage “prevents shared caches from serving stale content”.

How to Set It on Your Platform

Where your site runsWhat to do
CloudflareCaching → Configuration → Browser Cache TTL (default 4 hours). It replaces lower or missing origin values unless you pick Respect Existing Headers. Cache Rules can set Browser TTL per rule.
LiteSpeed Cache pluginCache → Browser: turn on Browser Cache (off by default in the docs); Browser Cache TTL 31557600 is the recommended value.
LiteSpeed serverWebAdmin → Server → General → Expires Settings. LiteSpeed warns that Expires Default “applies to all content types, including HTML”; leave it unset if you use LSCache.
HostingerUse the LiteSpeed Cache plugin’s Browser tab or an .htaccess block like the one below. If you copy Hostinger’s 2021 tutorial, drop its ExpiresDefault “access plus 7 days” line, which also covers HTML.
Apachemod_expires sets max-age and Expires; use mod_headers (Header set Cache-Control) for other directives.
nginxexpires (default off) sets Expires and max-age; add_header Cache-Control for anything else.
From each vendor’s documentation, checked 26 November 2026.

An Apache example for static files (in .htaccess or the server config):

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
</IfModule>

And an nginx one, inside your server block:

location ~* \.(css|js|webp|png|jpg|svg|woff2)$ {
    expires 365d;
}

I wrote both from the docs but didn’t run them on a test server. ExpiresByType must match the Content-Type your server sends: this site serves JS as application/x-javascript, which Hostinger’s text/x-javascript line wouldn’t match. In nginx, an add_header inside a location stops it inheriting add_header lines from above. Using LiteSpeed Cache? See LiteSpeed Cache settings.

Why Your Changes Don’t Show

The browser, the CDN and the page cache each keep their own copy. Purging one doesn’t always clear the others, and no server-side purge reaches a visitor’s browser. Cloudflare: “Purging Cloudflare’s cache does not affect assets stored by a visitor’s browser.” A file with a one-year max-age and an unchanged URL stays old for returning visitors. To fix it, clear every cache layer on Hostinger or purge LiteSpeed Cache, give the changed file a new URL (a new version string or file name), then recheck with curl.

Does Cache-Control Help Speed and SEO?

It lets repeat visitors skip downloads. I found no Google statement that Cache-Control is a ranking factor. Google’s Search Central blog (December 2024) says its crawlers support caching through ETag and Last-Modified, and suggests setting max-age “to help crawlers determine when to recrawl the specific URL”. I didn’t measure load times, so I make no speed claim. Caching works alongside Gzip or Brotli compression, not instead of it.

Mistakes to Avoid

  • Reading no-cache as “don’t cache”. It allows storing; use no-store to forbid it.
  • A catch-all default that covers HTML. It can serve visitors stale pages.
  • public on personal pages. MDN warns personal content in a shared cache can leak to other users.
  • Checking only with curl -I. Cloudflare’s HEAD and GET answers differed in my test.
  • Purging the CDN and expecting browsers to update. Browser copies stay until they expire or the URL changes.
Cache-Control checklist: check HTML, CSS, JS and images with a GET, long max-age and immutable for versioned files, no-cache for HTML, private for personal pages, purge and change URLs after updates

Checklist in text: check Cache-Control with a GET for the HTML, a CSS, a JS and an image file; give versioned static files at least 30 days (a year is common) plus immutable; give HTML no-cache or a short max-age; mark personal pages private; avoid catch-all defaults that cover HTML; read Age and the CDN status header; after changes, purge the page cache and CDN and change asset URLs.

What does Cache-Control max-age mean?

It’s the number of seconds a stored copy stays fresh. max-age=31536000 is one year (365 days); max-age=0 makes it stale at once, so caches normally check with the server before reusing it.

What is the difference between no-cache and no-store?

no-cache lets caches keep a copy but check with the server before each reuse. no-store says keep no copy.

What is s-maxage in Cache-Control?

A lifetime for shared caches such as CDNs only. Browsers ignore it.

How do I check the Cache-Control header of a website?

In Chrome DevTools (F12), open Network, reload, click a request and read cache-control. Or run curl -sS -o /dev/null -D – https://site.com/ | grep -i cache-control (in PowerShell: curl.exe -sS -o NUL -D – https://site.com/ | findstr /i cache-control).

How do I fix “Use efficient cache lifetimes” in Lighthouse?

Give the listed files a max-age of at least 30 days (2592000 seconds) through your CDN, LiteSpeed Cache’s Browser tab, Apache mod_expires or nginx expires. Other domains’ files are up to their owners.

Should HTML pages have a long Cache-Control max-age?

Usually not; returning visitors may see old pages. MDN suggests no-cache.

Harshil Barot
About the author
Digital Marketing Strategist & SEO Specialist

Harshil Barot is a digital marketing strategist focused on SEO, website growth and lead generation. He has built websites since 2012 and provided digital marketing services since 2016. His reviews of web hosting, WordPress, SEO and AI tools state whether they draw on personal use, hands-on testing or editorial research.

Share

Leave a Comment