Skip to content

How to set long cache lifetimes for static files

Speed1 min readFixes check cache-ttl

Images, fonts, CSS and scripts rarely change. Telling browsers to keep them for a year makes every repeat visit faster.

Step by step, with screenshots: Cache-Control for humans: what to cache, how long, how to bust it →

Check your own site

Runs this check and the other 186, free, in about 45 seconds.

What a passing site looks like

  • Static files have long cache lifetimeswarning · −2 ptseffort S

Static file caching

Why it matters. Images, fonts, CSS and JS rarely change, yet without a long Cache-Control lifetime returning visitors download them again on every page.

How to fix it.
  1. Set Cache-Control max-age of a year on versioned static files (most CDNs and caching plugins have a "browser caching" switch).
  2. Add a version or hash to file names so you can still change them.

Filed under Speed & Core Web Vitals. Copy is generated from the same catalogue that scores every report, so what you read here is what the report says.