WordPress Caching Deep Dive: Settings to Handle Viral Traffic Without Crashing
When a post goes viral, most WordPress sites don’t die because of “too much traffic.” They die because every single visitor triggers full PHP and database work. Caching fixes that.
This guide goes deeper into caching than the overview in our main performance article. You’ll learn how to configure page cache, object cache, browser cache and CDN cache in a way that lets a modest server survive massive spikes in traffic.
1. How Page Caching Actually Works
Normally, every page load in WordPress goes like this:
- The web server receives a request.
- PHP runs WordPress core, plugins and theme.
- WordPress queries the database many times.
- The final HTML is sent to the browser.
With page caching, this expensive process happens only once per URL. The result is saved as static HTML on disk or memory. Next visitors simply get the cached HTML file, which is incredibly cheap to serve.
2. Disk vs Memory Cache
Most plugins cache pages on disk. That’s fine for the majority of sites, but extremely busy sites benefit from having cache files served from memory (RAM) using tools like Redis or Varnish.
- Disk cache: Easier to configure, still very fast.
- Memory cache: Lower latency, better for extreme concurrency, more complex.
If you’re using standard shared or managed WordPress hosting, disk cache is likely what you have access to. Focus on tuning its rules instead of chasing exotic tools.
3. Smart Cache Rules for Dynamic Sites
Good caching is not “cache everything forever.” It’s cache as much as you can, as long as you can, without breaking dynamic features.
- Always bypass cache for logged-in users, carts, checkout and dashboards.
- Serve cached pages to anonymous visitors whenever possible.
- Use separate cache variants for mobile/desktop only if your theme truly needs it.
WooCommerce, LMS plugins and membership plugins all provide recommended “do not cache” URLs. Copy those into your caching plugin’s exclude settings.
4. Cache Preloading & Warming
Without preloading, pages are generated only when the first visitor hits them. That means the first visitor after a cache clear suffers a slow load. With preload, your plugin crawls the site and builds fresh cache in the background.
- Schedule preload to run after content updates or every few hours.
- Prioritize key pages: homepage, category pages, top posts.
If you’re expecting a big campaign or email blast, warm the cache for those specific URLs just before sending traffic.
5. Coordinating Cache Layers: Plugin + CDN + Browser
Think of caching as layers:
- Browser cache – visitor’s device.
- CDN cache – edge locations near visitors.
- Server page cache – your origin server.
Set long browser cache lifetimes for static assets (images, CSS, JS) and use cache-busting file names when assets change. Configure your CDN to respect or override those headers and to cache HTML where appropriate.
6. Purging Without Killing Your Site
Full cache purges are expensive. Avoid clearing the entire cache on every content change. Instead:
- Only purge the post you updated and its archive pages.
- Use “Purge this URL” instead of “Purge all” whenever possible.
- During big sales or launches, schedule purges carefully and monitor server load.
7. Load Testing Your Caching Setup
Before you depend on caching to handle viral traffic, simulate it with load testing tools. Start small and increase requests per second until you find the breaking point. Fix bottlenecks, then test again.
Even a small VPS can handle astonishing traffic numbers with correctly configured caching. The keys are: high cache hit rate, simple HTML output, and minimal backend work per uncached request.
Combine this deep caching setup with the main performance guide on wpscaleup and you’ll be ready for your next viral spike.