Glossary

What is Caching in WordPress?

February 8, 2026

Caching stores a copy of generated content so it can be served faster on subsequent requests, without regenerating it from scratch. For WordPress, this means skipping PHP execution and database queries for repeated page views. A WordPress page that takes 800ms to generate from scratch can be served in under 50ms when cached. Caching is one of the most impactful optimizations you can make for any WordPress site.

The Five Types of WordPress Caching

Caching in WordPress is not a single thing. There are five distinct layers, each working at a different point in the request cycle. Understanding what each one does helps you choose the right caching strategy for your site.

Browser Cache

The browser cache is the first layer and works entirely on the visitor's device. When a browser downloads a CSS file, an image, or a JavaScript file, it stores a local copy. On the next page load, the browser checks whether the cached copy is still valid (based on Cache-Control, Expires, and ETag headers) and skips the download entirely if it is. This eliminates network requests and makes subsequent page views feel almost instant for returning visitors.

You control browser caching through HTTP response headers. The most important ones are:

  • Cache-Control: max-age=31536000: Tells the browser to cache the file for one year (31,536,000 seconds). Used for versioned static assets that get a new filename when they change.
  • Cache-Control: no-cache: The browser must check with the server before using the cached copy. The server can respond with "304 Not Modified" if the file has not changed, saving bandwidth.
  • Cache-Control: no-store: The browser must never cache this response. Used for sensitive or highly dynamic content.

Page Cache

Page caching is the biggest performance win for most WordPress sites. Here is the problem it solves: on every page request, WordPress loads its core, initializes the database connection, runs dozens of database queries, processes plugin hooks, and renders theme templates. This PHP/MySQL cycle takes anywhere from 200ms to several seconds depending on your server and the complexity of your site. It produces the same HTML output for every anonymous visitor.

A page cache stores that HTML output after the first request. When the next visitor requests the same page, the cached HTML file is served directly by the web server (or even by a reverse proxy in front of it), completely bypassing WordPress, PHP, and the database. The difference is dramatic. Instead of running 50-200 database queries and executing thousands of lines of PHP, the server simply reads a file and sends it.

Object Cache

The object cache sits between WordPress and the database. WordPress frequently queries the same data repeatedly within a single page load and across page loads: options, user metadata, post data, transients. The object cache stores these query results in memory (using Redis or Memcached) so they do not hit the database every time.

WordPress has a built-in object cache, but by default it only works within a single request (it does not persist between requests). To get persistent object caching, you need a drop-in plugin that connects WordPress to Redis or Memcached. Popular options include Redis Object Cache and Object Cache Pro.

Object caching is particularly valuable for sites that cannot use full page caching, such as WooCommerce stores with personalized content, membership sites, or forums where content changes frequently.

Opcode Cache (OPcache)

Every time PHP processes a script, it first compiles the human-readable PHP code into bytecode (machine-readable instructions). This compilation step is repeated on every request unless opcode caching is enabled. PHP's built-in OPcache extension stores the compiled bytecode in shared memory, eliminating the compilation step for subsequent requests.

OPcache is a server-level setting, not something you configure through WordPress. Most modern hosting environments have OPcache enabled by default. You can verify this by checking your PHP configuration (phpinfo) or asking your hosting provider. OPcache alone can improve PHP execution speed by 30-50%.

CDN Cache

A CDN (Content Delivery Network) caches your static assets on edge servers distributed around the world. When a visitor in Tokyo requests an image from your WordPress site hosted in Amsterdam, the CDN serves it from a nearby edge server instead of routing the request all the way to Amsterdam. This reduces latency for static assets significantly. Some CDN providers like Cloudflare also offer full-page caching for WordPress through their APO feature. For more details, see our article on Content Delivery Networks.

How Page Caching Works Step by Step

Since page caching has the largest impact, here is a closer look at how it works in practice:

  1. A visitor requests yourdomain.com/about/ for the first time.
  2. WordPress processes the request normally: PHP runs, the database is queried, the theme template is rendered, and the HTML is generated.
  3. The caching plugin saves a copy of the finished HTML to the file system (typically in wp-content/cache/) or to memory.
  4. A second visitor requests yourdomain.com/about/.
  5. The caching plugin intercepts the request before WordPress loads. It finds the cached HTML file and serves it directly. PHP barely executes, and the database is not touched.
  6. When the page content changes (a post is updated, a comment is approved), the cache for that specific page is invalidated, and the next request generates a fresh copy.

Comparing Popular WordPress Caching Plugins

There are many caching plugins available for WordPress. Here are the most widely used ones and how they compare:

  • WP Rocket: A premium plugin (starting at $59/year) that is widely considered the most user-friendly caching solution. It enables page caching, browser caching, GZIP compression, and lazy loading out of the box with minimal configuration. WP Rocket also handles CSS/JS minification, database optimization, and integrates with Cloudflare for CDN cache purging. It is the best choice for site owners who want great performance without spending hours on configuration.
  • W3 Total Cache: A free plugin with an enormous range of features. It supports page caching, object caching (Redis, Memcached, APCu), browser caching, CDN integration, and minification. The downside is complexity. W3 Total Cache has dozens of settings pages, and misconfiguration can break your site. It is powerful but better suited for developers or advanced users.
  • WP Super Cache: A free plugin developed by Automattic (the company behind WordPress.com). It focuses on page caching and keeps things simple. WP Super Cache generates static HTML files and can serve them using mod_rewrite rules, which is very fast. It lacks the advanced features of WP Rocket and W3 Total Cache but is reliable and easy to configure.
  • LiteSpeed Cache: A free plugin that provides exceptional performance when used with LiteSpeed web servers. It supports page caching, object caching, image optimization, CSS/JS minification, and CDN integration. If your hosting uses LiteSpeed (many shared hosts do), this plugin takes advantage of server-level caching that is faster than PHP-based caching. It also works on Apache and Nginx but with reduced functionality.

Server-Level Caching Solutions

Beyond WordPress plugins, caching can also happen at the server level, which is often faster because it intercepts requests before PHP is even involved:

  • Varnish: A reverse proxy cache that sits in front of your web server. Varnish stores full page responses in memory and serves them directly for cached requests. It is extremely fast (sub-millisecond response times) and used by high-traffic WordPress sites. Configuration requires VCL (Varnish Configuration Language), which has a learning curve.
  • Nginx FastCGI Cache: If your server uses Nginx (which many modern WordPress hosts do), FastCGI caching stores the full PHP output and serves it directly from Nginx for subsequent requests. This is faster than any PHP-based caching plugin because Nginx handles the request entirely without invoking PHP. Many managed WordPress hosts (Kinsta, GridPane, SpinupWP) use this approach.
  • Redis Full-Page Cache: Some setups use Redis not just for object caching but for full-page caching as well. The cached HTML is stored in Redis memory, and a small PHP script or Nginx module serves it directly. This combines the speed of in-memory storage with the flexibility of key-based cache invalidation.

Object Caching with Redis and Memcached

For WordPress sites that deal with heavy database loads, persistent object caching can be transformative. Here is how the two main options compare:

  • Redis: The more popular choice for WordPress. Redis stores data in memory and supports complex data types (strings, hashes, lists, sets). It can persist data to disk, supports replication, and can be used for both object caching and session storage. The Redis Object Cache plugin is the most common way to connect WordPress to Redis.
  • Memcached: An older, simpler in-memory caching system. Memcached is fast and lightweight but lacks Redis's data persistence and advanced features. It is still used in some hosting environments, particularly older ones.

Persistent object caching makes the biggest difference on sites with complex queries: WooCommerce stores with thousands of products, BuddyPress communities, multisite networks, or any site where the WordPress admin dashboard feels sluggish.

When Caching Causes Problems

Caching is not always straightforward. There are situations where aggressive caching creates issues:

  • Logged-in users: Page caching must not serve cached pages to logged-in users, because each user sees different content (their name in the header, admin bar, personal dashboard). All major caching plugins handle this correctly by default, but custom implementations sometimes get it wrong.
  • WooCommerce and e-commerce: Shopping carts, checkout pages, and "my account" pages are dynamic and user-specific. They must be excluded from page caching. WP Rocket and LiteSpeed Cache automatically exclude WooCommerce pages. With other plugins, you may need to configure exclusions manually.
  • Dynamic content and AJAX: If your site relies heavily on AJAX-loaded content, real-time data, or personalized elements (recently viewed products, user-specific recommendations), full-page caching can serve stale content. Solutions include fragment caching (caching everything except dynamic parts) or loading dynamic content via JavaScript after the cached page loads.
  • Membership sites: Sites with multiple membership levels show different content to different user groups. Page caching needs to account for these variations, either by skipping the cache for logged-in users or by maintaining separate cached versions per user role (which most plugins do not support).
  • Forms and nonces: WordPress uses nonces (number-used-once tokens) for security in forms. If a page with a form is cached, all visitors get the same nonce, which can expire and cause form submission errors. Caching plugins usually handle this, but it is a common source of issues with custom forms.

Cache Invalidation: The Hard Part

There is a famous saying in computer science: "There are only two hard things in computer science: cache invalidation and naming things." Cache invalidation is the process of clearing or updating cached content when the underlying data changes. In WordPress, this means:

  • When you publish or update a post, the cache for that post, its category archives, tag archives, the homepage, and any page that displays recent posts should be cleared.
  • When you change theme settings, the entire page cache should be cleared because every page might look different.
  • When a new comment is approved, the cached version of that post should be updated to show the new comment.

Good caching plugins handle most of these scenarios automatically through WordPress hooks. They listen for events like save_post, switch_theme, and wp_update_comment_count and clear the relevant cache entries. However, if you have custom code that changes content without going through WordPress's standard functions, the cache may not be invalidated correctly.

When in doubt, most caching plugins provide a "Purge All Cache" button in the WordPress admin bar. Use it after making significant changes if cached pages are not reflecting your updates.

What InspectWP Checks

InspectWP detects whether a WordPress caching plugin is active by looking for cache-related HTML comments (many plugins insert a comment like <!-- Cached by WP Rocket --> at the bottom of the page), response headers (like X-Cache, X-Cache-Enabled, or X-LiteSpeed-Cache), and known plugin signatures in the page source. The report identifies which caching plugin is in use, so you can verify that your caching setup is working correctly. If no caching is detected, InspectWP flags this as a performance improvement opportunity, since caching is one of the most effective ways to speed up any WordPress site.

Check your WordPress site now

InspectWP analyzes your WordPress site for security issues, SEO problems, GDPR compliance, and performance — for free.

Analyze your site free