PageSpeed: Serve Static Assets With Efficient Cache Policy
Last updated: April 2026
Your static assets (JS, CSS, images) have no cache headers or short TTLs. Returning visitors re-download resources they already have. Add long-lived Cache-Control headers.
Fix for Nginx
location ~* \.(js|css|woff2|woff)$ {
expires 1y;
add_header Cache-Control "public, max-age=31536000, immutable" always;
}
location ~* \.(png|jpg|jpeg|webp|svg)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000" always;
}
Fix for Cloudflare
Dashboard โ Caching โ Cache Rules โ Create rule: file extension matches js, css, png, jpg, webp โ Edge TTL = 1 year.
Fix for Vercel
{
"headers": [{ "source": "/_next/static/(.*)",
"headers": [{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }]
}]
}
Why immutable matters
The immutable directive tells browsers not to revalidate during the max-age window, even on page reload. Use it only for fingerprinted assets (files with a hash in the name).