Skip to main content
KadiCache
Lighthouse: uses-long-cache-ttl · Server & Network10 min read1,034 wordsVerified 2026-11-23

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.

Serve static assets with an efficient cache policy (uses-long-cache-ttl) WordPress optimization diagram
0.000 Layout Shift6 Sections✓ Verified
Lighthouse Audit ID
uses-long-cache-ttl
Metrics Affected
TTFB · LCP
KadiCache Solution Tier
Free Core
3-Step Quick Action Plan (Schema HowTo)
STEP 01
Enable Verified Static Browser Cache in KadiCache -> Cache

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!).

STEP 02
Set Cloudflare Browser Cache TTL to 1 Year (or Respect Headers)

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.

STEP 03
Delay Short-TTL Third-Party Analytics & Ad Scripts

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.

WP Admin -> KadiCache -> Page Cache
MODULE Server & Network · 2X RETINA
Page caching, pre-WordPress Early Delivery drop-in, nonce-safe TTL presets, and browser cache headers.2880×1840 WebP
⚡ Executive Summary · 30-Second Spec100% Code-Verified
WP Admin Path
WP Admin -> KadiCache -> Cache + Cloudflare + CSS & JavaScript
Measured Impact
Instant 0 ms Disk-Cache Hits on Repeat Visits · 100% Free Core
DevTools Proof Marker
Lighthouse ID: uses-long-cache-ttl | max-age=31536000, immutable
  • Lighthouse inspects Cache-Control: max-age and Expires HTTP headers on every static sub-resource (.css, .js, .woff2, .webp, .jpg, .svg) and expects max-age >= 31536000 (365 days) for full credit.
  • First-Party vs Third-Party Split: Check the domain column first! You control Cache-Control headers on your own domain / CDN, whereas google-analytics.com (2h) and connect.facebook.net (20m) belong to external servers (solved by Delay JS!).
  • Cloudflare’s Classic 4-Hour Gotcha: By default, many new Cloudflare zones override origin Cache-Control headers with a 4-hour Browser 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 .htaccess and rolls back automatically if the server returns HTTP 500 or ignores mod_headers!
Table of Contents (6 sections)

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 ms network time on page #2, #3, and #4)!
FIG 01Self-verifying static asset browser cache headers alongside Early Delivery inside WP Admin -> KadiCache -> CacheZoom 2x

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:

NGINXProduction Nginx 1-Year Static Asset Cache + Font CORS Block
# 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:

APACHEApache / LiteSpeed 1-Year Immutable Static Cache Rules
<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 with max-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 bytes over 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 InsightsCurrent Cache TTL ShownExact Fix in Under 60 Seconds
Your domain .css, .js, .webp, .woff2 (None or 0 ms)NoneEnable 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 d4 hCloudflare 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 hEnable 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 hEnable Delay JS Until Interaction in KadiCache -> CSS & JavaScript so external short-TTL pixels don’t load on initial boot!
FIG 02Synchronizing Cloudflare edge and browser cache TTL headers without breaking dynamic WordPress HTMLZoom 2x

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:

  1. Checks host capabilities (HostCapabilities.php) and Multisite primary-site ownership (NetworkBrowserRules.php) before touching .htaccess.
  2. Writes isolated # BEGIN KadiCache rules and immediately probes a live same-site CSS URL + homepage HTTP status.
  3. If the homepage returns HTTP 500 (home_500) or headers had zero effect (ineffective due to front-proxy Nginx), KadiCache rolls back the .htaccess edit automatically and displays the exact diagnostic status inside WP Admin -> KadiCache -> Cache!
  4. Verifies Gzip/Brotli text compression alongside static cache headers—and on WordPress Multisite networks, coordinates .htaccess rules 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?
Pure Nginx servers (such as LEMP stacks, RunCloud Native Nginx, SpinupWP, or Kinsta) ignore Apache .htaccess files completely for performance reasons—static header rules live inside /etc/nginx/sites-available/ instead. Copy the 8-line Nginx snippet from this guide (or KadiCache -> CDN modal) and reload Nginx once!
What does the immutable directive in Cache-Control: public, max-age=31536000, immutable actually do?
Without immutable, hitting Reload (F5) in some browsers sends conditional 304 If-Modified-Since revalidation requests for all 40 CSS/JS/font/image sub-resources on the page! Adding immutable tells browsers the versioned file will never change before expiry, skipping even 304 round-trips on reload.
Why does Cloudflare Turnstile or Stripe.js still show a short 5-minute TTL if I’m testing a /checkout/ page?
Payment security SDKs (js.stripe.com/v3/) intentionally use short TTLs so Stripe can deploy urgent fraud-prevention patches worldwide within minutes. Keep security SDKs intact on /checkout/—they have near-zero impact on public catalog/landing page scores.
Does enabling Cloudflare “Cache Everything” without WordPress cookie bypasses fix this audit safely?
Never create a raw wildcard Cache Everything Page Rule without cookie bypasses—that caches wp-admin bars and logged-in WooCommerce customer details! Always use KadiCache’s built-in Cloudflare -> Edge Caching & APO integration, which enforces full WordPress & WooCommerce cookie safety.
Will updating my WordPress theme logo or editing Additional CSS reflect immediately with 1-year static caching?
Yes! WordPress Customizer attachment uploads generate new filenames, and KadiCache’s inline/optimized CSS updates the cached HTML snapshot immediately on Save & Purge.
Verified WordPress Fix · uses-long-cache-ttl
Clear “Serve static assets with an efficient cache policy” without breaking Elementor or WooCommerce.
E-E-A-T Source Verified

Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.

apps/wordpress-plugin/src/Cache/Delivery/StaticBrowserCache.phpapps/wordpress-plugin/src/Optimization/CdnUrlRewriter.phpapps/wordpress-plugin/src/Integrations/Cdn/CdnUrl.php
Connected Topical Cluster · Continue Deepening Your Setup