
Caching Strategy: 5 Cache Layers to Make Your Site Lightning Fast
Browser cache, server cache, object cache, CDN, and opcache – combined they make your website 10x faster.
Author: Meiko Neuman
Founder and web strategist, Kodulehe Haldus
Cache = Memory
Cache stores a previously calculated result so it doesn't have to be recalculated the next time. A correctly configured cache turns a 3-second page into a 0.3-second one.
5 Cache Layers
1. Browser Cache The visitor's browser stores files locally – they won't be reloaded on the next visit.
Cache-Control: public, max-age=31536000, immutable
(1 year for static files)
2. CDN Cache [CDNs](/blogi/cdn-cloudflare-vs-bunny) hold a copy of the server globally. The request only reaches your server if the CDN cannot provide a response.
3. Server-side Page Cache Entire HTML pages are pre-generated and stored.
WordPress plugins: - WP Rocket – premium, the best - W3 Total Cache – free, powerful - LiteSpeed Cache – for LiteSpeed servers - WP Super Cache – official by Automattic
4. Object Cache (Redis/Memcached) Database queries are stored in memory. Critical for active WordPress sites.
# Redis setup on Ubuntu
sudo apt install redis-server
WP plugin: Redis Object Cache.
5. PHP OPcache A pre-compiled version of PHP code in memory. Standard equipment in PHP 7+.
Check: <?php phpinfo(); ?> → search for OPcache.
Recommended config:
`ini
opcache.enable=1
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0 ; production
`
Cache Invalidation
"There are only two hard things in Computer Science: cache invalidation and naming things." – Phil Karlton.
Rule: every content change invalidates the cache.
Automatic - WordPress: WP Rocket/W3TC invalidates automatically - After post update - After comment
Manual - Admin Bar → Purge cache - Via API call (after deployment) - CLI: `wp cache flush`
Cache Strategy for Different Content
| Content | Cache Time | Strategy |
|---|---|---|
| Logo, CSS, JS | 1 year | Versioned URL (style.css?v=2) |
| Products (E-shop) | 1 hour | Invalidate after change |
| Homepage | 30 min | Invalidate after new post |
| Cart | 0 | NO cache |
| Admin | 0 | NO cache |
| API endpoint | varies | Per route |
Measurement
Before and after cache configuration:
| Metric | Without Cache | With Cache |
|---|---|---|
| TTFB (Time to First Byte) | 800ms | 80ms |
| Server CPU | 60% | 5% |
| Database Queries | 80/pg | 5/pg |
| Concurrent users (max) | 100 | 5000+ |
Common Mistakes
- Caching dynamic content (cart, login)
- Cache time too short (missing out on the main cache benefit)
- Old cache after update (user sees an old version)
- Same cache for different users (privacy risk)
- Same cache for mobile/desktop (responsive design solves this)
WooCommerce Specifics
For e-shops: - ❌ Do not cache: cart, checkout, my-account - ✅ Cache: products, categories, homepage - ✅ Fragment caching for dynamic parts
Real-world Example
Client (WooCommerce, 5000 products): - Before: TTFB 1.2s, page loads in 4.8s - After (all 5 layers): TTFB 90ms, page loads in 0.8s - 6x faster
Revenue increased by 18% over the next 30 days.
Summary
Caching is not optional in 2026. Every missing layer costs you customers. See also: - Lazy loading - Core Web Vitals - CDN Comparison
Our optimization service sets up all 5 layers in one week – guaranteed 50%+ speed improvement. Request a quote.
Sources
Need help with your website?
Our team maintains, optimises and protects your website. Pricing is agreed based on scope.
Request a quoteAbout the author
Meiko Neuman — Founder and web strategist, Kodulehe Haldus. Meiko leads the Kodulehehaldus team and has spent over a decade helping companies maintain and optimise their websites for measurable business results. He writes about website management, SEO, AEO/GEO and the commercial side of the web.