How to Fix Browser Caching Headers on Static Assets
This check fails when at least half of your site's own static files (CSS, JavaScript, images, fonts) are served without a Cache-Control max-age of at least 7 days, or with no-cache or no-store. By the end of this guide your versioned static assets will return a header like `Cache-Control: public, max-age=31536000, immutable`, while your HTML stays fresh.

Why it matters
Without a long max-age, returning visitors re-download or revalidate every stylesheet, script and image on each page view. That adds network round trips, slows Largest Contentful Paint on repeat visits and internal navigation, and increases bandwidth and server load. Faster repeat loads improve Core Web Vitals field data, which Google uses as a ranking signal, and lower bounce rates on slow mobile connections.
What you need
Step-by-step fix
Check your current asset headers
Open a page, then DevTools → Network, reload, click a CSS, JS, image or font file from your own domain and look at Response Headers. Or use curl. The audit only counts first-party assets returning HTTP 200 and needs a max-age value of at least 604800 (7 days).
An Expires header alone does not count, and any no-cache or no-store fails the asset even if max-age is present.
curl -sI https://www.example.com/assets/app.css | grep -i -E 'cache-control|expires|etag'
Confirm your asset URLs are versioned
A one-year cache is only safe if the URL changes whenever the file changes. Look for a content hash in the filename (app.3f9a1c.css) or a version query string (style.css?ver=6.5.2). If your files are plain style.css with no version, add versioning first (most bundlers like Vite and webpack do this by default in production builds); otherwise use a shorter but still passing value such as 7–30 days.
Set Cache-Control on Nginx
Add a location block for static extensions inside your server block. Nginx's add_header in a location replaces headers inherited from the parent level, so repeat any security headers (HSTS, CSP) inside this block if you set them globally. Then run sudo nginx -t && sudo systemctl reload nginx.
location ~* \.(css|js|mjs|png|jpg|jpeg|gif|webp|avif|svg|ico|woff2?)$ {
add_header Cache-Control "public, max-age=31536000, immutable" always;
access_log off;
try_files $uri =404;
}Or set it on Apache / .htaccess
On Apache or LiteSpeed hosting (common for WordPress), add this to the .htaccess in your site root. It requires mod_headers, which is enabled on almost all shared hosts. Remove any older ExpiresByType rules that set short lifetimes for the same types to avoid conflicting values.
<IfModule mod_headers.c>
<FilesMatch "\.(css|js|mjs|png|jpe?g|gif|webp|avif|svg|ico|woff2?)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
</IfModule>Remove conflicting no-cache rules
Search your config, CDN rules and plugins for anything adding no-cache, no-store or private, max-age=0 to static files. These often come from a global header meant for HTML or logged-in pages. The audit fails an asset if either directive appears anywhere in its Cache-Control header, even alongside a long max-age.
grep -rn -E 'no-cache|no-store|max-age=0' /etc/nginx/ .htaccess 2>/dev/null
Purge your CDN and re-test
g. Cloudflare → Caching → Configuration → Purge Everything) so edge servers pick up the new headers, then repeat the curl test on a CSS, JS, image and font URL. Each should show max-age of 604800 or higher and no no-cache/no-store.
Finally, rerun the audit.
for u in /assets/app.css /assets/app.js /images/logo.webp /fonts/inter.woff2; do echo "$u"; curl -sI "https://www.example.com$u" | grep -i cache-control; done
Platform-specific notes
WordPress
Use the .htaccess rule on Apache/LiteSpeed hosts, or ask managed hosts (Kinsta, WP Engine) who set headers at Nginx level. Caching plugins can do it too: W3 Total Cache → Performance → Browser Cache, or WP Rocket's built-in browser caching rules. WordPress appends ?ver= to enqueued CSS/JS, so long max-age is safe for theme and plugin assets.
Shopify
You cannot edit server headers. Theme files loaded via the `asset_url` and `image_url` Liquid filters are served from /cdn/shop/ with versioned URLs and long cache lifetimes automatically. If assets fail, check for files hardcoded to unversioned URLs or served through an app proxy, and switch them to the filters.
Next.js / Vercel
Files under /_next/static already get `public, max-age=31536000, immutable`. Don't apply that header to `/(.*)`, which would also freeze HTML and API responses. Instead add a `headers()` rule in next.config.js (or vercel.json) scoped to files in /public, e.g. source `/images/:path*` or `/fonts/:path*`, and rename those files when they change.
Cloudflare
Caching → Configuration → Browser Cache TTL defaults to 'Respect Existing Headers'. To override, create a Cache Rule (Caching → Cache Rules) matching static extensions, set Browser TTL to 'Override origin' with 1 year. Cloudflare will not lower a longer origin max-age.
Wix / Squarespace / Webflow
Headers are controlled by the platform and their CDN-hosted assets already use long, versioned caching. Failures usually come from files you self-host elsewhere on your own domain; fix those at that server.
Check that it worked
✅ How to verify
- Run `curl -sI https://www.example.com/path/to/file.css` and confirm Cache-Control shows max-age=604800 or higher with no no-cache/no-store.
- In Chrome DevTools → Network, reload twice: static assets should show '(memory cache)' or '(disk cache)' in the Size column.
- Run Lighthouse and check the 'Serve static assets with an efficient cache policy' / 'Use efficient cache lifetimes' insight no longer lists your own files.
- Rerun this audit and confirm fewer than half of sampled first-party assets are flagged.
⚠️ Common mistakes
- Applying a one-year immutable header to HTML pages or the whole site, so visitors keep seeing old content after updates.
- Relying on an Expires header or ETag alone; the check requires an explicit max-age of at least 7 days.
- Setting long max-age on unversioned filenames, then wondering why CSS changes don't appear for returning visitors.
- Adding add_header in an Nginx location block and unknowingly dropping security headers defined at the server level.
Is this still an issue on your site? Run a free audit — ZORO checks this and 294 other SEO, AI-visibility, accessibility and security signals, with fixes for your platform.
Check my site freeFAQ
What is a good Cache-Control max-age for CSS and JS?
For files with a hash or version in the URL, use `public, max-age=31536000, immutable` (one year). For unversioned files, 7 to 30 days (604800 to 2592000 seconds) balances speed against stale content.
Does browser caching affect SEO?
Indirectly. It speeds up repeat visits and multi-page sessions, which improves Core Web Vitals field data from real Chrome users, a page experience signal Google uses. It does not change how Googlebot indexes content.
Why does Lighthouse still flag Google Analytics or other third-party scripts?
You can't control headers on files served from other domains. This audit ignores third-party assets, so focus only on files served from your own domain.
Will long caching stop visitors from seeing my site updates?
Not if asset URLs are versioned and HTML is not long-cached. When a file changes, its URL changes, so the browser fetches the new version, while unchanged files load instantly from cache.
How to Fix Next-Gen Image Formats: Serve WebP and AVIF
How to Enable Gzip or Brotli Compression on Your Website
How to Fix Oversized Images and Cut Homepage Image Weight
How to Fix Unminified CSS and JavaScript Files on Your Site
How to Fix Missing Lazy-Loading on Offscreen Images
How to Fix Render-Blocking Resources on Your Website