What are caching headers (Cache-Control)?

Crawvix Editorial Team · Published November 1, 2026 · Last updated November 1, 2026 · 2 min read

Caching headers are HTTP response headers, mainly Cache-Control, that tell browsers and CDNs whether they may keep a copy of a file and for how long. Long lifetimes for versioned images, scripts and styles make repeat visits faster, while HTML pages usually need a short lifetime or revalidation so updates appear.

Why it matters

Without caching instructions, a browser may download the same logo and stylesheet on every page view. With them, it reuses the stored copy. That saves bandwidth and speeds up repeat visits. The cost is that a cached file can go stale, so lifetimes must match how often the file changes.

How to do it

The values you will meet

  • max-age=31536000 keeps a file for a year (the number is seconds).
  • public allows shared caches such as CDNs to store it; private limits it to the visitor's own browser.
  • immutable says the file will never change at that address, so the browser need not check again.
  • no-cache lets the browser store the file but forces it to check with the server before reuse. Despite the name, it does not mean "do not store".
  • no-store tells caches not to keep the response at all, which suits sensitive pages.
  • s-maxage sets a separate lifetime for shared caches such as CDNs.

Related validators, ETag and Last-Modified, let the browser ask "has this changed?" and receive a short "not modified" answer.

Steps

  1. Give files whose names change when their content changes (for example app.3f9a1c.css) a long lifetime:
Cache-Control: public, max-age=31536000, immutable
  1. Give HTML pages a short lifetime or revalidation:
Cache-Control: no-cache
  1. For files with fixed names such as logo.png, use a moderate lifetime, such as a day or a week, unless you can rename them on change.
  2. Check the result:
curl -sI https://example.com/css/site.css | grep -i -E "cache-control|etag|last-modified"
  1. Confirm in Chrome DevTools: reload and see (disk cache) in the Size column of the Network panel.

Common mistakes

  • Giving a year-long lifetime to files with fixed names, so visitors keep old versions after you update them.
  • Caching HTML for too long so new content takes ages to show.
  • Using no-cache and expecting it to stop storage; use no-store for that.
  • Caching logged-in or personal pages in a shared cache.
  • Forgetting that a CDN can have its own cache rules, separate from browser headers.

Frequently asked questions

What is a good cache lifetime?

For fingerprinted static assets, a year is common. For HTML, use no-cache or a short value. In between, choose a lifetime that matches how often the file changes.

How do I update a cached file?

Change its file name or add a version to its address, then update the references. Visitors then fetch the new file immediately.

Does caching affect SEO?

Fast repeat visits help the experience. Stale caching of HTML can delay updates, so keep page lifetimes short.

Crawvix's scan checks that static files have cache headers. To see yours, Try the free website sample.

In this category

All 100 Quick answers guides