Back to blog
    Header image for the article "Caching Strategy: 5 Cache Layers to Make Your Site Lightning Fast"
    Optimization06/06/20267 min

    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

    ContentCache TimeStrategy
    Logo, CSS, JS1 yearVersioned URL (style.css?v=2)
    Products (E-shop)1 hourInvalidate after change
    Homepage30 minInvalidate after new post
    Cart0NO cache
    Admin0NO cache
    API endpointvariesPer route

    Measurement

    Before and after cache configuration:

    MetricWithout CacheWith Cache
    TTFB (Time to First Byte)800ms80ms
    Server CPU60%5%
    Database Queries80/pg5/pg
    Concurrent users (max)1005000+

    Common Mistakes

    1. Caching dynamic content (cart, login)
    2. Cache time too short (missing out on the main cache benefit)
    3. Old cache after update (user sees an old version)
    4. Same cache for different users (privacy risk)
    5. 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 quote

    About 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.

    Related articles