How to Fix “Serve static assets with an efficient cache policy” in WordPress
Lighthouse triggers “Serve static assets with an efficient cache policy” when local CSS, JS, WOFF2 fonts, or WebP images ship missing or short Cache-Control max-age headers—forcing repeat shoppers to re-download unchanged assets.

Open WP Admin -> KadiCache -> Cache and toggle ON Static files browser cache so StaticBrowserCache.php installs and self-verifies 1-year Cache-Control rules (with automatic HTTP 500 rollback safety!).
Using Cloudflare? Open WP Admin -> KadiCache -> Cloudflare -> Edge Caching & APO and ensure Cloudflare is not overriding your origin’s 1-year static headers down to 4 hours.
Third-party URLs (gtm.js, fbevents.js, analytics.js) intentionally ship 15m–2h TTLs on external servers; enable Delay Until Interaction in CSS & JavaScript to clear them from initial load.
- Lighthouse inspects
Cache-Control: max-ageandExpiresHTTP headers on every static sub-resource (.css,.js,.woff2,.webp,.jpg,.svg) and expectsmax-age >= 31536000(365 days) for full credit. - First-Party vs Third-Party Split: Check the domain column first! You control
Cache-Controlheaders on your own domain / CDN, whereasgoogle-analytics.com(2h) andconnect.facebook.net(20m) belong to external servers (solved by Delay JS!). - Cloudflare’s Classic
4-HourGotcha: By default, many new Cloudflare zones override originCache-Controlheaders with a4-hourBrowser Cache TTL—causing every image and font on your site to fail this audit until adjusted! - Verified KadiCache Safety (
StaticBrowserCache.php): Probes a real same-site CSS response after editing.htaccessand rolls back automatically if the server returnsHTTP 500or ignoresmod_headers!
Table of Contents (6 sections)
- Why Static Files Can Safely Cache for 1 Full Year Without Serving Stale Designs
- Manual Nginx & Apache Configuration Snippets (1-Year Immutable)
- How max-age=31536000, immutable Accelerates Multi-Page WooCommerce Shopping Sessions
- Diagnosis Matrix: Fixing Every Row Inside uses-long-cache-ttl
- Inside StaticBrowserCache.php: Why KadiCache Never Leaves Broken .htaccess Edits
- Pull-CDN CNAME Rewriting (CdnUrlRewriter.php): Offloading Static Assets Globally
Why Static Files Can Safely Cache for 1 Full Year Without Serving Stale Designs#
Developers sometimes hesitate to set a 1-year (31,536,000 seconds) Cache-Control policy on .css and .js files out of fear that visitors will stay stuck on an old stylesheet after a theme update.
In WordPress and KadiCache, URL cache-busting solves staleness completely:
- WordPress appends
?ver=6.7.1(or file-hash versions) to enqueued stylesheets and scripts. - KadiCache’s minified/optimized assets carry content-hashed filenames—meaning the instant a single CSS rule or JS line changes, the URL itself changes (
app.a8f31c.css→app.91d04e.css) and browsers fetch the new file immediately while caching unchanged files on local NVMe/flash storage for 365 days (0 msnetwork time on page #2, #3, and #4)!
Manual Nginx & Apache Configuration Snippets (1-Year Immutable)#
On Apache and LiteSpeed servers, KadiCache’s StaticBrowserCache.php writes and verifies .htaccess rules automatically. On pure Nginx servers (which do not read .htaccess files by design—detected automatically by StaticBrowserCache.php as Needs manual setup on Nginx), add this clean location block inside your server {} config and run nginx -t && systemctl reload nginx:
# Static versioned assets: 1-year browser & CDN edge cache
location ~* \.(?:css|js|mjs|webp|avif|jpe?g|png|gif|ico|svg|woff2?)$ {
expires 365d;
add_header Cache-Control "public, max-age=31536000, immutable";
access_log off;
}
# Cross-origin webfont header when serving local WOFF2 via a Pull-CDN CNAME
location ~* \.(?:woff2?|ttf|otf)$ {
expires 365d;
add_header Cache-Control "public, max-age=31536000, immutable";
add_header Access-Control-Allow-Origin "*";
}Running Apache or LiteSpeed where .htaccess writes are locked by deployment permissions (kadicache_disable_htaccess)? Here is the exact Apache mod_headers + mod_expires equivalent you can place inside your virtual-host config:
<IfModule mod_headers.c>
<FilesMatch "\.(css|js|mjs|webp|avif|jpe?g|png|gif|ico|svg|woff2?)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
<FilesMatch "\.(woff2?|ttf|otf)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>How max-age=31536000, immutable Accelerates Multi-Page WooCommerce Shopping Sessions#
While Lighthouse grades single-page loads, the biggest commercial payoff of a 1-year static cache policy happens when a shopper clicks from Landing Page → Category Page → Product Page → /cart/ → /checkout/:
- Page #1 (Cold Cache): Browser downloads HTML (
~18 KB), local subsetted.woff2(~22 KB), and deferred core JS (~34 KB), storing static assets in local flash disk cache withmax-age=31536000, immutable. - Pages #2 through #5 (Warm Browser Disk Cache): Fonts, brand logos, icons, and shared scripts load from local memory/disk cache in
0.2 ms(0 bytesover cellular 4G)—making/checkout/paint near-instantaneously even though/checkout/HTML itself safely bypasses page caching!
Diagnosis Matrix: Fixing Every Row Inside uses-long-cache-ttl#
| Asset Row Flagged in PageSpeed Insights | Current Cache TTL Shown | Exact Fix in Under 60 Seconds |
|---|---|---|
Your domain .css, .js, .webp, .woff2 (None or 0 ms) | None | Enable Static files browser cache in WP Admin -> KadiCache -> Cache (or add the Nginx block above on pure Nginx) |
Every asset on your domain shows 4 h (14,400 s) or 7 d | 4 h | Cloudflare Browser Cache TTL override! Open KadiCache -> Cloudflare -> Edge Caching (or Cloudflare Dashboard -> Caching -> Configuration) and set Browser Cache TTL to Respect Existing Headers or 1 year! |
fonts.googleapis.com/css2 (1 d TTL) | 24 h | Enable Self-Host Google Fonts in KadiCache -> Fonts so fonts serve from your 1-year origin cache! |
googletagmanager.com, google-analytics.com (2 h), fbevents.js (20 m) | 15 m – 2 h | Enable Delay JS Until Interaction in KadiCache -> CSS & JavaScript so external short-TTL pixels don’t load on initial boot! |
Inside StaticBrowserCache.php: Why KadiCache Never Leaves Broken .htaccess Edits#
Many legacy WordPress caching plugins blindly dump mod_expires directives into .htaccess—causing an instant HTTP 500 Internal Server Error on minimal Apache containers where AllowOverride FileInfo is disabled! KadiCache’s StaticBrowserCache.php prevents outages via a 4-step verification loop:
- Checks host capabilities (
HostCapabilities.php) and Multisite primary-site ownership (NetworkBrowserRules.php) before touching.htaccess. - Writes isolated
# BEGIN KadiCacherules and immediately probes a live same-site CSS URL + homepage HTTP status. - If the homepage returns HTTP
500(home_500) or headers had zero effect (ineffectivedue to front-proxy Nginx), KadiCache rolls back the.htaccessedit automatically and displays the exact diagnostic status insideWP Admin -> KadiCache -> Cache! - Verifies Gzip/Brotli text compression alongside static cache headers—and on WordPress Multisite networks, coordinates
.htaccessrules centrally from the main network site (NetworkBrowserRules.php) so child subsites never overwrite shared server rules.
Pull-CDN CNAME Rewriting (CdnUrlRewriter.php): Offloading Static Assets Globally#
Serving WooCommerce product images, .woff2 fonts, and .css/.js files through BunnyCDN, CloudFront, or Fastly via WP Admin -> KadiCache -> CDN (Custom CDN & Varnish Guide)? KadiCache’s CdnUrlRewriter.php rewrites static asset URLs to your HTTPS CNAME (https://cdn.your-store.com) while preserving ?ver= cache-busting query strings so your CDN edge PoPs inherit your origin’s 1-year Cache-Control: public, max-age=31536000, immutable headers across 100+ countries automatically.
“Serve static assets with an efficient cache policy” — Frequently Asked Questions
Why does StaticBrowserCache.php say “Needs manual setup on Nginx” on my VPS?
What does the immutable directive in Cache-Control: public, max-age=31536000, immutable actually do?
Why does Cloudflare Turnstile or Stripe.js still show a short 5-minute TTL if I’m testing a /checkout/ page?
Does enabling Cloudflare “Cache Everything” without WordPress cookie bypasses fix this audit safely?
Will updating my WordPress theme logo or editing Additional CSS reflect immediately with 1-year static caching?
Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.
Configure Pull-CDN asset rewriting, Font CORS snippets, and Varnish.
Align Cloudflare Browser Cache TTL and Edge HTML caching cleanly.
Tame external analytics and chat scripts that ship 15-minute cache TTLs.
Explore KadiCache’s origin-to-edge cache coordination engine.