Skip to main content
+44 7575 472931[email protected]
HostaccentKnowledge BaseHosting, websites, SEO, and growth

Serve Static Assets With an Efficient Cache Policy: 2026 Fix

Serve static assets with an efficient cache policy in 2026: copy-paste Cache-Control rules for Apache, Nginx and Cloudflare, plus third-party script fixes.

Website PerformanceWordPressCloudflare
Serve static assets with an efficient cache policy: Cache-Control headers set in Apache, Nginx and Cloudflare

PageSpeed just flagged a list of your CSS, JavaScript and image files, and you want that warning gone. To serve static assets with an efficient cache policy, your server has to tell browsers to keep those files for at least 30 days instead of downloading them again on every visit. On most sites that's one block of config and about 10 minutes of work.

Our team resolves 20 to 30 client site issues a day, and missing cache headers are one of the quiet problems that keep coming back after redesigns and server moves. This guide is the checklist we actually work through, written so you can do it yourself.

Quick Answer: As of October 2026, Lighthouse and PageSpeed Insights flag any cacheable file (images, fonts, CSS, JavaScript, media) with a cache lifetime under 30 days. Fix it by sending Cache-Control: public, max-age=31536000, immutable for versioned static files from Apache (.htaccess), Nginx (a location block) or your CDN. Keep HTML on a short or zero cache, and handle third-party scripts separately, because you can't set their headers.

Last verified: October 2026, against Lighthouse 13 (the "Use efficient cache lifetimes" insight) and Cloudflare's current Browser Cache TTL documentation.

What This Warning Means in 2026 (and Why the Name Changed)

The warning means some of your static files tell the browser to throw them away too soon, or say nothing at all. Every returning visitor then downloads files they already have.

The label you see depends on the tool. Lighthouse 13, released in October 2025, retired the old audit and replaced it with an insight called "Use efficient cache lifetimes" (Google's Lighthouse 13 release notes list the swap). Older reports, GTmetrix-style tools and most guides on page one still use the longer audit name, and the oldest ones call it "Leverage browser caching". Same problem, three names.

As of October 2026, Google's own cache lifetimes insight documentation sets the bar at a cache lifetime of at least 30 days (2,592,000 seconds) for every cacheable subresource. A file counts as cacheable when it's a font, image, media file, script or stylesheet, returns a 200, 203 or 206 status, and doesn't explicitly opt out with no-cache, no-store or must-revalidate.

That last rule surprises people. A file marked no-cache is not flagged at all, because Lighthouse assumes you chose that on purpose.

The report shows three columns: the request URL, its current Cache TTL and the transfer size you'd save. A TTL of "None" means no header; "4 h" usually means a CDN filled the gap with its default.

One honest point most guides skip: this insight doesn't subtract points from your Performance score directly. The score comes from metrics like LCP and CLS. What short cache lifetimes really cost you is slower repeat visits, wasted bandwidth and worse real-user data for returning visitors, which can feed into Core Web Vitals failing on your hosting.

Why Your Static Files Get Flagged: Causes Ranked by Frequency

In our experience, five causes explain almost every case, and the first two cover most of them.

  1. No Cache-Control header at all. Fresh servers, custom stacks and new Nginx configs often send static files with zero caching instructions.
  2. A CDN default filling the gap. When your origin sends nothing, Cloudflare applies its default Browser Cache TTL of 4 hours, which fails the 30-day bar.
  3. Rules in the wrong layer. Your .htaccess has perfect rules, but Nginx sits in front and serves images and CSS directly, so Apache never sees those requests.
  4. Third-party files. Analytics tags, ad pixels, chat widgets and video embeds load from domains you don't control.
  5. A short TTL set on purpose. A plugin or developer picked 7 days because they were scared of stale CSS after updates.

According to Hostaccent's support-queue data (October 2026), WordPress problems make up about 30% of our monthly tickets, and "slow for returning visitors" cases inside that slice regularly trace back to cause 2 or cause 3 rather than to the code itself.

Cause 3 deserves a closer look. On our own Cloudflare to Nginx to Apache stack, Nginx answers static file requests itself for speed, so any rule that only lives in .htaccess does nothing for those files. If your host runs a similar proxy setup, the fix has to happen at the Nginx or CDN layer.

Why does PageSpeed still complain after I installed a caching plugin?

Because most caching plugins cache your pages, not your file headers. Page caching stores finished HTML on the server so PHP doesn't rebuild it every time. Browser caching is a different job: it's the Cache-Control header attached to each CSS, JS and image response. Some plugins write .htaccess rules for that too, but those rules only work when Apache actually serves the file.

How to Serve Static Assets With an Efficient Cache Policy on Apache, Nginx and Cloudflare

Set a one-year Cache-Control header on versioned static files at whichever layer actually serves them, then confirm the CDN isn't shortening it. Before you edit anything, run each flagged URL through what our team calls the Owner-Server-Version triage:

  • Owner: is the file on your domain? If not, skip to the third-party section.
  • Server: who answers the request: Apache, Nginx or a CDN? Check the server and cf-cache-status response headers.
  • Version: does the URL change when the file changes (for example style.css?ver=6.8 or app.4f9c2.js)? If yes, a one-year cache is safe.

Apache and LiteSpeed: Cache-Control headers in .htaccess

Add this to the .htaccess file in your site root (usually public_html). LiteSpeed reads the same rules.

apache
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/avif "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType text/javascript "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType text/html "access plus 0 seconds"
</IfModule>

mod_expires writes both an Expires date and a matching Cache-Control: max-age value. Browsers prefer Cache-Control when both exist, as MDN's Cache-Control reference explains, so this one block covers you. The HTML line keeps your pages fresh while the files they reference stay cached.

Browser caching in Nginx

If Nginx serves your static files, add a location block inside the right server { } block:

nginx
location ~* \.(?:css|js|mjs|woff2?|svg|png|jpe?g|gif|webp|avif|ico|mp4|webm)$ {
    add_header Cache-Control "public, max-age=31536000, immutable";
    access_log off;
    try_files $uri =404;
}

Then test and reload: sudo nginx -t && sudo systemctl reload nginx. If the reload goes wrong and the site starts throwing errors, our guide to the 502 Bad Gateway in Nginx walks through the usual causes.

Pro Tip: Nginx's add_header has an inheritance trap. If a location block contains any add_header line, it silently drops every add_header from the parent server block, including security headers like HSTS. Copy those lines into the static-file block too, or move them into a shared include file. The Nginx headers module documentation describes this behaviour.

Live site and no time to experiment? Our engineers can set and test these cache rules for a small one-time fee, and you'll see the exact quote before anyone touches your server. Hosted with Hostaccent? Then this is simply covered by support, free. Have an engineer fix it

Cloudflare and other CDNs

This is the step older guides leave out. If your origin sends no header, Cloudflare substitutes its default Browser Cache TTL of 4 hours, and that's the "4 h" you see in the report. Go to Caching > Configuration > Browser Cache TTL and either pick Respect Existing Headers (once your origin sends one-year headers) or choose a value of 1 month or longer.

Cloudflare's Edge and Browser Cache TTL documentation adds two details worth knowing. Cloudflare only overrides your origin when its own setting is longer, and purging Cloudflare's cache doesn't clear files already stored in visitors' browsers. That second point is why versioned URLs matter so much.

The WordPress gotcha: replaced images keep their old cache

WordPress adds ?ver= query strings to theme and plugin CSS and JS, so a one-year cache is safe there: each update changes the URL. Images in wp-content/uploads don't get that treatment. If you overwrite logo.png with a new file of the same name, returning visitors keep the old one for up to a year. Upload the new version under a new filename instead.

Professional help available

Still blocked at Cloudflare?

Send the error code, affected hostname, and recent DNS or SSL changes. We will separate edge, origin, firewall, and certificate causes before proposing work.

Request Cloudflare helpExplore Cloudflare supportHosted elsewhere? One-time paid support is available after scope and price confirmation.

Third-Party Scripts You Can't Control

You can't change cache headers on files served from Google, Meta or any other outside domain, so those rows may never fully clear. Analytics and ad tags use short lifetimes on purpose, so tag changes reach browsers quickly.

As of October 2026, third-party tags are the most common reason a site still shows cache warnings after its own files are fixed, and a one-year header on your server cannot touch a script loaded from another domain. Your realistic options are to delay those scripts, move tracking server-side, or replace heavy embeds with lightweight placeholders.

Third-party fileWhy it's flaggedBest practical move
Analytics and tag manager scriptsShort TTL by designDelay until user interaction, or move to server-side tagging
Ad and social pixelsShort TTL, extra requestsLoad after first interaction
Video embedsHeavy player filesUse a click-to-load preview image
Hosted web fontsExtra domain, separate cacheSelf-host the font files with your one-year rule

We built our own server-side tagging setup (server-side GTM in Docker, sending GA4 and Meta conversions) and found the trade-off is real: fewer browser-side scripts, but one more container to patch and monitor. For a brochure site, delaying tags until the first scroll or click is usually enough.

Be careful with plugins that download a local copy of an analytics script. The copy passes the audit, but if it isn't refreshed often it falls behind Google's version and can quietly break tracking. For the bigger picture on what a CDN can and can't fix here, see when a CDN for WordPress helps and when it won't.

How to Confirm the Fix and Stop It Coming Back

Check the actual response headers first, then re-run the report. Headers are proof; a score alone isn't.

From a terminal, request one flagged file and read its headers:

bash
curl -sI https://example.com/wp-content/themes/yourtheme/style.css | grep -iE "cache-control|expires|cf-cache-status"

You want to see max-age=31536000 (or at least 2592000) on the cache-control line. In Chrome, open DevTools with Ctrl+Shift+J, click the Network tab, reload twice, and check the Size column: cached files show "(disk cache)" or "(memory cache)" instead of a byte count.

A fixed site should clear the PageSpeed cache TTL warning on the next run for every first-party file, typically within minutes of the config change once any CDN cache has been purged. Rows that remain should all be third-party domains, which the previous section covers.

Pro Tip: Keep your cache rules inside the site's own files (.htaccess or a versioned Nginx include) rather than only in a server-wide config. Across the 4,000+ site migrations Hostaccent has handled since 2016, a pattern we see repeatedly is cache rules that lived only on the old server and silently vanished during the move.

Prevention comes down to three habits: version your asset URLs (most build tools add content hashes automatically), recheck headers after every migration or CDN change, and re-run PageSpeed after major theme updates. If repeat visits are fine but the first load is still slow, the bottleneck is elsewhere, so start with how to fix high TTFB in WordPress or the full WordPress slow site diagnosis guide.

Your Next Step: Keep Repeat Visits Fast

Fixed it? Keep one habit: check response headers after every migration, because that's when cache rules disappear. You can now serve static assets with an efficient cache policy on your own, but on a well-managed host, cache headers, CDN settings and server rules are support's job, not yours. Hostaccent's Economy plan at $1.99/mo (renews at the same $1.99/mo) runs on NVMe storage with 24/7 human support from our own engineers and a 30-day money-back guarantee. It's sized for a single site, so if you run several, Standard fits better. Start on the Economy shared hosting plan.

Still stuck? Open a ticket with our engineers. It's a small one-time fee, and you'll see the exact quote before any work starts.

Frequently Asked Questions

What does serve static assets with an efficient cache policy mean?

It means some images, fonts, CSS or JavaScript files on your page tell browsers to discard them too quickly, or send no caching instructions at all. Returning visitors then download files they already have. As of Lighthouse 13 the same check appears as "Use efficient cache lifetimes", and it flags any cacheable file with a lifetime under 30 days. The fix is a Cache-Control header set on your server or CDN.

How long should static assets be cached?

Versioned files whose URL changes when the content changes, like style.css?ver=6.8 or app.4f9c2.js, should be cached for one year (31,536,000 seconds) with immutable. Files that keep the same URL after edits need either a version string added or a shorter lifetime with revalidation. HTML pages should usually get a short or zero cache so visitors always see current content. Google's minimum to pass the check is 30 days.

Will long cache times show visitors outdated CSS after an update?

Only if the file's URL stays the same. WordPress appends a version number to theme and plugin CSS and JavaScript, so every update creates a new URL and browsers fetch it fresh. The real risk is images or files you overwrite under the same name, which can stay cached for up to a year. Rename replaced files, use build-tool hashing for custom code, and you can safely use long lifetimes.

Can I fix the cache warning for Google Analytics or Facebook Pixel?

Not directly. Those files load from domains you don't control, and their short lifetimes are deliberate so tag updates reach users fast. You can reduce their impact by delaying them until the visitor scrolls or clicks, or by moving tracking to a server-side tagging setup. Downloading a local copy also clears the warning, but stale copies can break tracking, so keep that approach for sites that monitor it closely.

Does browser caching improve my PageSpeed score?

Not directly. Lighthouse calculates the Performance score from metrics such as Largest Contentful Paint and Cumulative Layout Shift, and the cache insight is diagnostic advice rather than a scored item. Lab tests also load your page with an empty cache. The real gain shows up for returning visitors, who skip re-downloading files, which improves their load times, reduces your bandwidth and can lift the real-user Core Web Vitals data Google collects.

Why is Cloudflare showing a 4-hour cache TTL on my files?

Cloudflare's default Browser Cache TTL is 4 hours, and it applies that value whenever your origin server sends no Cache-Control or Expires header. Lighthouse sees 4 hours and flags the file because it's under the 30-day minimum. Either add one-year headers at your origin and set Browser Cache TTL to "Respect Existing Headers", or raise the Cloudflare setting to one month or longer in the Caching configuration page.

Professional help available

Still seeing the Cloudflare error? We can trace the edge and origin together.

Send the error code, affected hostname, and recent DNS or SSL changes. We will separate edge, origin, firewall, and certificate causes before proposing work.

  • No hosting transfer required
  • Scope confirmed before paid work
  • No changes before your approval
Request Cloudflare helpExplore Cloudflare supportHosted elsewhere? One-time paid support is available after scope and price confirmation.
Reviewed by

Hostaccent Editorial Team

Reviewed for technical accuracy and clarity before publication.

Last updated

Oct 29, 2026

HostAccent Editorial Team publishes practical hosting guides, operations checklists, and SEO-focused tutorials for businesses building international web presence.

Discussion

Have a question or tip about this topic? Share it below — your comment will appear after review.

Your email stays private and is only used for moderation.

Write for the Community

Have a tutorial, tip, or insight to share? Get published on the Hostaccent Blog with your name, bio, and website link.

Become a Contributor

Need a faster setup for this workflow?