PageSpeed fix guide ·

Use efficient cache lifetimes (Serve static assets with an efficient cache policy): how to fix it

PageSpeed Insights shows Use efficient cache lifetimes (formerly Serve static assets with an efficient cache policy) when your images, CSS, JavaScript or fonts tell the browser to keep them for less than 30 days, so returning visitors download them again. The fix: send Cache-Control: public, max-age=31536000 (one year) for static files whose URL changes when the file changes, and keep HTML and the cart, checkout and account pages out of long caching.

In PageSpeed Insights
Use efficient cache lifetimes
Older name
Serve static assets with an efficient cache policy
In a FlashMax report
Returning visitors may download files again

45.3% of the 40,951 WooCommerce stores FlashMax tested have this problem. See the study

The short fix

  1. Open the insight or the test report and note which of your own files have a short cache lifetime.
  2. Turn on browser caching in your cache plugin, or add a Cache-Control rule to the server config.
  3. Give versioned static files (CSS, JS, fonts, images) a one-year lifetime.
  4. Keep HTML and the Cart, Checkout and My Account pages without a long cache.
  5. Reload with DevTools open and confirm the new cache-control header.

What PageSpeed Insights is telling you

Lighthouse 13 replaced the old audit Serve static assets with an efficient cache policy with the insight Use efficient cache lifetimes, listed under Insights in PageSpeed Insights. It flags fonts, images, media, scripts and style sheets that may be cached (status 200, 203 or 206, and no header that forbids caching) but whose cache lifetime is under 30 days, or 2,592,000 seconds.

The list often includes third-party files, such as analytics or chat scripts. Only their owner can change those headers.

The FlashMax card Returning visitors may download files again counts only your own site's files. It appears when 50 KB or more of them expire within a week.

Why short cache lifetimes slow returning visitors

A cache lifetime tells the browser how long it may reuse its stored copy of a file. Within that time, the file comes from the visitor's own device instead of the network. Chrome's documentation notes that latency matters more than bandwidth, so skipping those requests makes repeat visits faster. A shopper who comes back next week gets your theme's CSS, scripts and fonts from their own device.

This doesn't change your Lighthouse score. The test measures a first visit, and the score comes only from the five metrics. The gain is for returning visitors, which lab tests don't see.

How common it is

In our study of 40,951 WooCommerce stores, 45.3% (18,559 stores) got this card. Their median phone score was 52, against 53 for stores without it. A gap that small is expected: the score measures a first visit, and cache lifetimes help the next one. As with every comparison of this kind, it is a correlation, not proof. See the WooCommerce speed study.

How to find the files with short lifetimes

In PageSpeed Insights, open Use efficient cache lifetimes: it lists the flagged files with their current cache lifetime. The free FlashMax test lists your own files behind the card, so third-party scripts don't get in the way.

To check one file in Chrome DevTools, open the Network panel, reload, click a CSS or image file and read cache-control (and expires, if present) under Response Headers. Reload again with Disable cache unticked: the Size column shows which files came from the cache instead of the network. From a terminal:

curl -sI https://example.com/wp-content/themes/your-theme/style.css | grep -i -E "cache-control|expires"

How to fix it on WordPress and WooCommerce

WordPress already versions most theme and plugin files. A file loaded the standard way gets a ?ver= query string, added for cache busting. The developer sets that number and should change it whenever the file changes; if they leave it out, WordPress uses its own version number, which changes only when WordPress updates. Versioned URLs are what make a one-year lifetime safe.

WP Rocket

When you activate WP Rocket, it adds browser caching rules to .htaccess on Apache and LiteSpeed servers, which need mod_expires enabled: one year for CSS and JavaScript, four months for images and fonts, and 0 seconds for HTML so pages are always checked for updates. On nginx it can't write the rules, so add them yourself (below). WP Rocket also warns that a Cloudflare setting, Caching > Browser cache expiration, can override its rules.

LiteSpeed Cache

In the plugin's Cache settings, open the Browser tab and turn Browser Cache on; it is off by default. The default Browser Cache TTL is 31557600 seconds (one year), which is also LiteSpeed's recommended value.

nginx by hand

location ~* \.(?:css|js|mjs|woff2?|ttf|otf|jpe?g|png|gif|webp|avif|svg|ico)$ {
    add_header Cache-Control "public, max-age=31536000";
}

nginx drops the add_header lines of the server block inside a location that has its own add_header, so copy any security headers into this block (or, on nginx 1.29.3 and later, add add_header_inherit merge; to it). If your config already has a location for these files, for example to serve WebP, add the header line there instead.

Apache by hand (.htaccess)

<IfModule mod_headers.c>
  <FilesMatch ".+\.(css|js|mjs|woff2?|ttf|otf|jpe?g|png|gif|webp|avif|svg|ico)$">
    Header set Cache-Control "public, max-age=31536000"
  </FilesMatch>
</IfModule>

Both rules give a year to every file with these extensions, so they are safe only when a changed file gets a new URL. WordPress adds ?ver= to CSS and JS loaded the standard way; if you overwrite images or fonts under the same name, give them max-age=2592000 (30 days) instead, the minimum the insight accepts. Use either a plugin's rules or your own, not both, so it's clear which lifetime applies.

What never gets a long cache

  • HTML pages. Use Cache-Control: no-cache (the browser may keep a copy but must check with the server first) or a short lifetime, so price and stock changes show up at once.
  • Cart, Checkout and My Account. WooCommerce says these pages must stay dynamic because they show one customer's data. The rules above only touch static files, so they leave these pages alone; never add them to a long-lifetime rule or a CDN cache.

Shopify and hand-built sites

Shopify doesn't let you edit server headers. If the card appears on a Shopify store, check which domain the listed files come from; files on other servers, such as an app's, can only be changed by whoever serves them, so the fix is to remove or replace the app.

Hand-built sites: put a hash or version number in each static file's name (app.3f9c2b.css) or query string (app.css?v=42), and serve those files with:

Cache-Control: public, max-age=31536000, immutable

immutable tells the browser not to recheck the file while it is fresh. Serve the HTML with Cache-Control: no-cache, so a new page always points to the new file names.

Mistakes to avoid

  • Long caching without versioned URLs. If you edit style.css by hand and its ?ver= stays the same, returning visitors keep the old file until it expires. Change the version, or the file name, with every edit.
  • immutable on files that change under the same URL. The browser won't check for a new copy until the lifetime runs out.
  • Replacing an image under the same name. Returning visitors keep the old picture until it expires. Upload the new one under a new name.
  • Caching HTML for a long time. Visitors see old prices, stock and banners. In a shared cache such as a CDN, cart and account pages could even be shown to the wrong customer.
  • Losing other headers in nginx. A location with its own add_header drops the ones from the server block, as described above.

How to check that it worked

Reload a page with DevTools open, click a CSS file and an image, and confirm a cache-control header with a long max-age. Click the page itself as well and make sure the HTML did not get the long header. Then re-test with FlashMax or PageSpeed Insights 2 or 3 times: the card and the insight should clear for your own files, even though the score barely moves.

Real-user data in PageSpeed Insights and Search Console includes repeat visits and covers the last 28 days, so any change there takes about four weeks.

Questions people ask

What cache lifetime does PageSpeed Insights want?

At least 30 days (2,592,000 seconds) for static files that may be cached; Chrome's documentation suggests a long lifetime of 30 days or one year. One year (31536000 seconds) is the usual choice for files whose URLs carry a version.

Why does the warning still list Google Analytics or Facebook files?

Those files are served from their owners' servers, so their cache headers are set there and you can't change them. Judge the warning by your own files; remove third-party scripts you don't need.

Is it safe to cache CSS and JavaScript for a year?

Yes, as long as the URL changes whenever the file changes. WordPress adds ?ver= to files loaded the standard way; if you edit a theme file by hand, change that version too.

Should HTML pages be cached in the browser?

Not for long. Use Cache-Control: no-cache or a short lifetime so visitors get current prices and stock, and never cache the cart, checkout or account pages.

Will longer cache lifetimes raise my PageSpeed score?

Not directly. The lab test measures a first visit, so cache lifetimes don't count toward the score. They make repeat visits faster, which real-user data can reflect over time.

Sources

  1. Use efficient cache lifetimes (Chrome for Developers)
  2. What's new in Lighthouse 13 (Chrome for Developers)
  3. Cache-Control header (MDN)
  4. Module ngx_http_headers_module (nginx.org)
  5. Apache module mod_headers (httpd.apache.org)
  6. wp_enqueue_style() (WordPress Developer Resources)
  7. How to configure caching plugins for WooCommerce (WooCommerce developer docs)
  8. Browser caching (WP Rocket documentation)
  9. Cache settings, Browser tab (LiteSpeed Cache for WordPress documentation)

Rather have it done?

The FlashMax team fixes the issues in your report, on a copy first, and shows the before-and-after.

See the speed optimization service

              AMERICANEXPRESSPayPalDISCOVERstripeVISA