How to fix "Serve static assets with an efficient cache policy"
This warning means your server does not tell browsers to keep images, CSS, JavaScript and fonts for long, so returning visitors download them again on every visit. The fix is to send a Cache-Control header with a long lifetime for files that rarely change.
Every page on your site is built from many small files: images, stylesheets, scripts and fonts. When a visitor opens a second page, or comes back next week, their browser can reuse files it already downloaded, but only if your server says it is allowed to. If your server says nothing, or says "keep this for 10 minutes", the browser fetches the same files again and again.
You usually see this problem as a Lighthouse or PageSpeed Insights warning called "Serve static assets with an efficient cache policy" (older versions said "Leverage browser caching"). It comes with a list of files and their current cache lifetime, often 0 seconds, 1 hour or 1 day.
Why it matters
Slow repeat visits cost you. A visitor who browses three pages should download your logo, fonts and stylesheet once, not three times. With a good cache policy, the second and later pages feel much faster, which helps people finish a purchase or enquiry instead of giving up.
It also affects your Core Web Vitals and the speed score Google reports. Caching does not change the very first visit much, but it reduces load on your server and your hosting bill, and it helps on slow mobile connections where every extra download hurts.
There is no security risk here, but there is a trust one: a site that feels slow on every click looks unprofessional.
How to check if your site has it
Two free ways:
- Open PageSpeed Insights, enter your address and look under Diagnostics for "Use efficient cache lifetimes" or "Serve static assets with an efficient cache policy". It lists each file and its cache duration.
- In Chrome, press F12, open the Network tab, reload the page, click a file such as your CSS and look at Response Headers. You want to see a line like
cache-control: public, max-age=31536000. If the line is missing, ormax-ageis small, that file is not cached well.
Note that the list often includes files from other companies, such as analytics, chat widgets or embedded maps. You cannot change their cache headers. Focus on the files that come from your own domain.
How to fix it in general
The fix is a Cache-Control header on static files. The common recipe is:
Cache-Control: public, max-age=31536000, immutable
max-age is in seconds, so 31536000 is one year. immutable tells the browser not to re-check the file at all during that time.
There is one catch. If you give a file a one year lifetime and later replace it under the same name, visitors may keep seeing the old version. Two safe approaches:
- Fingerprinted filenames such as
app.3f9c2a.css. The name changes whenever the content changes, so a one year lifetime is safe. Most modern build tools and many themes do this for you. - Shorter lifetimes (for example 30 days,
max-age=2592000) for files with plain names likestyle.cssorlogo.png.
Do not give your HTML pages a long cache lifetime. Pages change often, and you want visitors to get the latest version.
Fixing it on common platforms
Exact menus depend on your version, theme and host, so treat these as pointers.
WordPress. Caching plugins such as WP Rocket, W3 Total Cache or LiteSpeed Cache usually have a setting for browser caching, often under a cache or performance section. Turn it on and save. Some hosts already do this at server level. See the WordPress guide for more detail.
Nginx. Add a block to your site configuration, then reload Nginx. The Nginx guide covers it step by step.
location ~* \.(css|js|jpg|jpeg|png|gif|webp|avif|svg|woff2|ico)$ {
add_header Cache-Control "public, max-age=2592000";
}
Apache and cPanel. Most cPanel hosting runs Apache. In the File Manager, edit the .htaccess file in your site root (make a copy first) and add the following. It needs mod_headers, which most hosts have enabled. The Apache guide has more options.
<IfModule mod_headers.c>
<FilesMatch "\.(css|js|jpg|jpeg|png|gif|webp|avif|svg|woff2|ico)$">
Header set Cache-Control "public, max-age=2592000"
</FilesMatch>
</IfModule>
IIS. In web.config, inside system.webServer, add a staticContent section with <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />.
Cloudflare. Look under Caching, then Configuration, for "Browser Cache TTL", or use Cache Rules to set a browser TTL for static file types. Cloudflare can override your server headers, so check which one wins.
Netlify. Add a _headers file to your published folder with a path such as /assets/* followed by an indented Cache-Control: public, max-age=31536000, immutable line. Only do this for fingerprinted files.
If you are unsure which of these applies to you, ask your host or developer: "Can you set Cache-Control headers for static files on our domain?" That is a small, well understood request.
How to confirm the fix worked
- Clear your cache or use a private window, then reload the page with the Network tab open.
- Click a CSS or image file and check that the
cache-controlheader shows your new value. - Reload again. Files should now show "(disk cache)" or "(memory cache)" in the Size column instead of a download size.
- Run PageSpeed Insights again. The warning should shrink or disappear. Remaining items are usually third party files you cannot control.
If the header does not change, something else may be overriding it: a CDN, a caching plugin or a second rule in your configuration. Check each layer in turn.
How to stop it coming back
The problem usually returns when a site moves host, a plugin is switched off, a CDN is added or a server configuration is rebuilt. Keep a note of where your cache headers are set, and test again after any hosting or theme change.
Speed problems tend to travel together, so also look at render-blocking resources while you are in there. Checking once a year is not enough. SiteMonday's week 4 speed and Core Web Vitals service re-tests your site on a schedule and lists caching among the findings, with a ranked fix list your developer can work through.
Step by step for your platform
- No browser caching for static assets on WordPress
- No browser caching for static assets on Nginx
- No browser caching for static assets on Apache
- No browser caching for static assets on IIS
- No browser caching for static assets on Cloudflare
- No browser caching for static assets on cPanel
- No browser caching for static assets on Netlify
Questions
What is a good cache time for static assets?
One year (`max-age=31536000`) is common for files with fingerprinted names that change whenever their content changes. For files with plain names, 30 days is a safer choice.
Will long caching break my site when I update it?
It can, if you replace a file but keep the same name, because visitors may see the old copy. Use fingerprinted filenames or shorter lifetimes to avoid this.
Why does PageSpeed still list files after I fixed my own?
Those are probably third party files, such as analytics or chat widgets, served from other companies. You cannot change their cache headers.
Should I cache my HTML pages too?
Not for long. Pages change often, so keep their lifetime short or let the browser re-check them each time.
Does browser caching help first time visitors?
Not much, since they have nothing saved yet. It speeds up later pages and return visits, and reduces load on your server.
Do I need a developer to fix this?
Often not. A caching plugin or a hosting setting may be enough, but server configuration changes are easier with your host or a developer. SiteMonday reports the problem, and the fix itself is up to you or your developer.