How to set cache headers for static files
Cache-Control tells browsers how long to keep a file. Long lifetimes with versioned filenames make repeat visits instant.
Step by step, with screenshots: Apache .htaccess for an A grade: headers, redirects, caching →
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 a cache lifetimewarning · −1.5 ptseffort S
Cache lifetime for static files
Why it matters. Without a cache lifetime, every visit downloads the same logo, CSS and scripts again. Returning visitors should get them from their browser in 0 ms.
- Send Cache-Control: public, max-age=31536000, immutable for versioned images, CSS, JS and fonts.
- Most caching plugins and CDNs set this for you; check the "browser cache" or "edge TTL" setting.