Skip to main content

Fix Guides

How to Improve Browser and CDN Caching

Make repeat visits and static assets load instantly.

Quick fix

To improve caching, set Cache-Control: public, max-age=31536000, immutable on versioned static assets (CSS, JS, images with hashes), use no-cache or short TTL for HTML, enable CDN edge caching, and add ETags for efficient revalidation. Verify headers with DevTools or curl.

Without caching, every visit re-downloads everything. Correct Cache-Control headers tell browsers and CDNs how long to reuse files — free speed for returning visitors and lower server load.

Check your website

See how your site handles how to improve browser and cdn caching — free, no account needed.

Business impact

Caching cuts hosting costs and makes the site feel instant on repeat visits. It also reduces TTFB when HTML is cached at the edge. It is one of the highest-leverage server-side optimisations.

Why this happens

Missing or weak caching when: default server headers are no-cache; CDN not proxying; HTML cached too aggressively (stale content) or not at all; assets without fingerprinted filenames cached too short. Strategy: long cache for immutable versioned assets; short/no-cache with revalidation for HTML.

How to confirm the issue

Manually: DevTools → Network → click an asset → check Cache-Control response header.

With Plexa Trust: slow response findings improve when caching is configured; re-scan after changes.

Step-by-step fix

  1. Set long max-age + immutable on fingerprinted static files.

  2. Use no-cache or short max-age for HTML and API responses.

  3. Enable CDN caching and configure page rules for static paths.

  4. Add ETag or Last-Modified for efficient 304 responses.

  5. Version filenames (app.abc123.js) so long cache is safe.

  6. Verify headers on CSS, JS, images, and HTML separately.

Platform-specific fixes

Cloudflare

  1. Caching → Configuration → set Browser Cache TTL appropriately.

  2. Create Cache Rules for /static/* or file extensions with long TTL.

  3. Use "Cache Everything" only for pages safe to cache.

WordPress

  1. Caching plugin sets headers and page cache automatically.

  2. Configure browser cache TTL in plugin settings.

Nginx

  1. location ~* \.(css|js|png|jpg|webp)$ { expires 1y; add_header Cache-Control "public, immutable"; }

  2. Reload nginx after config change.

Apache

  1. Use mod_expires and mod_headers in .htaccess for static extensions.

  2. Set ExpiresByType for images, CSS, JS.

How to verify the fix

  • Fingerprint asset filenames when using long max-age.

  • Separate cache policy for HTML vs static assets.

  • Purge CDN cache on deploy when needed.

Common mistakes

  • Caching HTML for days so users see stale content.

  • Long cache on unversioned JS — users stuck on old bundles after deploy.

  • No caching at all on static assets.

Frequently asked questions

What is immutable?

Tells browsers the file will never change at that URL — safe with fingerprinted filenames.

no-cache vs no-store?

no-cache allows stored copies but requires revalidation. no-store forbids storing. HTML often uses no-cache.

Should HTML be cached?

Short TTL or no-cache with revalidation for dynamic HTML; longer at CDN for static marketing pages if safe.

How does CDN caching differ from browser cache?

CDN caches at the edge for all users; browser cache is per visitor. Use both.

What are ETags?

Validators that let browsers ask "changed?" and get 304 Not Modified without re-downloading.

Can caching break my site after deploy?

Only if assets are cached without versioned URLs. Use hashes in filenames.

Does caching help SEO?

Indirectly — faster pages improve experience signals and crawl efficiency.

How do I confirm it worked?

Static assets show long max-age in DevTools; repeat loads come from cache (disk/memory).

Think you've fixed it?

Run a free scan to verify the issue is resolved. Upgrade to Pro on Plexa Trust for the full audit, monitoring alerts, and score history.

Verify with a free scan

Upgrade to Pro for monitoring