---
title: "WordPress Caching Explained: Page, Browser, Object, OPcache and CDN"
description: "WordPress caching explained layer by layer, measured on a test site: page cache, browser cache, object cache, OPcache and CDN, and which ones you need."
url: "https://skybootstrap.com/wordpress-caching-explained/"
canonical_url: "https://skybootstrap.com/wordpress-caching-explained/"
date: "2026-12-06T06:01:00+06:00"
modified: "2026-11-22T16:44:14+06:00"
author: Skybootstrap Team
type: article
site: SkyBootstrap
language: en-US
---

# WordPress Caching Explained: Page, Browser, Object, OPcache and CDN

WordPress caching means keeping a ready-made copy of something so it doesn’t have to be built again. This guide covers five cache layers: whole pages, files in the visitor’s browser, database results, compiled PHP code, and copies on a CDN. Each saves a different wait, and on our test site some mattered far more than others.

All the test results below come from a single offline WordPress 7.1.3 test install rather than a real site; defaults and thresholds come from the documentation we link. Treat the results as before-and-after comparisons on that machine.

## WordPress caching explained: the layers at a glance

The five cache layers sit at different points between your server and the visitor’s screen. A page cache, OPcache, and an object cache run on your server, the browser cache lives on the visitor’s device, and a CDN sits in between.

**Here’s what each one stores and what it did on our test site:**

| Layer | Where it lives | What it stores | What it did on our test site |
| --- | --- | --- | --- |
| Page cache | Your server or host | Finished HTML pages | Server response time (same machine): 886 ms, then 0.5 ms with the cache |
| Browser cache | The visitor’s browser | CSS, JavaScript, images | No lifetime by default (each reuse checked, “304” with 0 bytes); 30-day lifetime after our change |
| Object cache | Server memory (Redis, Memcached) | Database query results | 39 queries down to 0; faster only when the database was slow to reach |
| OPcache | PHP on your server | PHP code, already compiled | Uncached page 54 ms with it, 203 ms without |
| CDN | Servers in many places | Static files, sometimes whole pages | Not tested (no real visitors in our lab) |

## Page cache: finished pages for visitors

A page cache stores each finished page so the server can send it without running WordPress or the database. The [WordPress handbook’s cache page](https://developer.wordpress.org/advanced-administration/performance/cache/) puts it first: “WordPress caching is the fastest way to improve performance.”

On our test site, a slow test plugin made every page wait, and the page cache cut the server response time (measured on the same machine) from 886 ms down to half a millisecond. The cache we used was nginx’s fastcgi_cache, configured in the server itself.

On shared or managed hosting, look in your hosting dashboard, or ask support whether a page cache is included; otherwise, a caching plugin adds one. We didn’t test host panels or caching plugins.

**A page cache doesn’t help every visit. On our server:**

- Right after we emptied the cache, the next visit was a MISS and took 0.89 to 0.90 seconds, because WordPress had to build the page.
- The next visit was a HIT in under a millisecond.
- A logged-in visit skipped the cache (BYPASS) and took 902 ms.

That’s why logged-in users and pages that change for each visitor still depend on everything behind the cache.

**What a page cache can’t fix.** It can’t fix what happens in the browser. On the same test site, the page cache removed the server wait completely, yet the mobile Lighthouse score stayed at 59. Our test plugin had also added a full-size, lazy-loaded main image and 1.1 MB of render-blocking CSS and JavaScript, and those were still slowing the page. For the slow work a page cache only hides, and for those browser-side problems, start with our WordPress speed guide.

## Browser cache: files the visitor already has

The browser cache is the store of files a visitor’s browser keeps, so a returning visitor can reuse CSS, JavaScript, and images they downloaded before. It depends on headers your server sends with each file.

An ETag is a fingerprint that changes when the file changes. Our nginx server sent one with each file, but no Cache-Control lifetime.

So the browser had to ask each time whether the file had changed. When it asked with the ETag, the server answered “304 Not Modified” with 0 bytes, the exchange the handbook describes as answering “304 responses, confirming that a file is unchanged”. Lighthouse still flagged “Use efficient cache lifetimes”.

Cache-Control is the header that tells the browser how long it may reuse a file without asking. We added it with nginx’s [expires directive](https://nginx.org/r/expires), which sets “Cache-Control: max-age” in seconds. This went in the site’s `server` block:

```
location ~* \.(css|js|jpe?g|png|webp|gif|svg|woff2?)$ { expires 30d; }
```

Our files then came with `Cache-Control: max-age=2592000`, which is 30 days, and Lighthouse’s “Use efficient cache lifetimes” insight passed.

The line goes in your site’s nginx file; on Ubuntu that’s usually in `/etc/nginx/sites-available/`, and ours was `speed.conf`. Copy the file first, for example `sudo cp yoursite.conf yoursite.conf.bak`, then run `sudo nginx -t` and `sudo nginx -s reload`. If the file already has a `location` for these file types, add `expires 30d;` inside it instead of a second block. To undo, remove the line, test and reload; browsers that already stored a file may keep using it until its 30 days run out.

On shared hosting, or Apache, a caching plugin or your host sets these headers; we didn’t test those routes.

## Object cache: fewer database trips

WordPress’s object cache keeps database results in memory so the same query isn’t run twice. The [WPObjectCache reference](https://developer.wordpress.org/reference/classes/wp_object_cache/) says “By default, the object cache is non-persistent”, meaning it lasts only for one request. A persistent object cache keeps those results between requests, in a memory store such as Redis, a database server that keeps data in RAM, or Memcached.

`object-cache.php` is a drop-in, a file WordPress loads in place of part of its own code. When it sits in `wp-content`, WordPress loads it instead of its built-in cache; with Redis Object Cache, that cache is persistent.

The plugin needs a Redis server your host provides, or you install. On our site, activating the plugin didn’t create the file; its enable command did. Site Health then reports “A persistent object cache is being used”.

Our results show when it helps. With Redis Object Cache 3.0.0 on our test post, database queries fell from 39 to 0. With the database on the same server, the page took 52.8 ms without Redis and 50.4 ms with it, which is no real difference.

Then we put a 1 ms delay between WordPress and the database, standing in for a database on another server. The same post took 128.2 ms without Redis and 61.4 ms with it. With that 1 ms delay, Redis roughly halved the post’s server time; we didn’t test a busy database. Our Redis object cache guide covers the set-up and how to undo it.

## OPcache: compiled PHP code

OPcache keeps PHP’s compiled code in memory so PHP doesn’t rebuild every WordPress file on every request. It’s part of PHP, not WordPress. With OPcache switched off, our uncached test page took 203 ms instead of 54 ms, nearly four times as long.

The [PHP manual](https://php.net/manual/en/opcache.configuration.php) lists `opcache.enable` with a default of 1 (on) and `opcache.revalidate_freq` with a default of 2 seconds. That’s how often PHP checks whether a file has changed. Ours used both defaults.

To check yours without a terminal, look for “Opcode cache is enabled” under **Tools > Site Health**, as shown below. If it isn’t listed there, ask your host whether OPcache is on. On a VPS, `php -i | grep opcache.enable` showed `opcache.enable => On` on our server; that command reads the command-line PHP settings, which can differ from the web server’s.

## CDN: copies closer to visitors

A content delivery network (CDN) is a set of servers in many countries holding copies of your files, so each visitor downloads from the nearest one. WordPress’s Site Health code includes `cf-cache-status` among the cache headers it checks. The handbook adds that “Some newer CDN will also include Full Page Caching (FPC) or Edge Caching which will cache the entire HTML content of the website.”

The handbook also says “The distance between your server and your website visitors also has an impact on performance.” We couldn’t test that: our lab site has no real visitors and sits on one machine.

## Check which caches your site already uses

WordPress’s Site Health screen checks three of these layers for you, no terminal needed. Open **Tools > Site Health**, then **Passed tests**. On our test site, with all three running, it listed:

![WordPress Site Health passed tests showing opcode cache enabled, a persistent object cache in use and a page cache detected](https://skybootstrap.com/wp-content/uploads/2026/11/wordpress-caching-site-health-cache-checks.webp "Test site, 3 Nov 2026: WordPress 7.1.3 with an nginx page cache, OPcache and Redis Object Cache 3.0.0.")

The page cache check looks for an active page-cache plugin, or makes three requests to your home page and looks for cache headers such as `x-cache`, `cf-cache-status` and `age`. It calls the server response time good under 600 ms.

If your cache adds none of those headers, Site Health may not spot it, so check the headers too: in your browser’s developer tools, open the Network tab, click the page itself, and look at its response headers. Header names differ by host, and our `X-Cache` header was added by our own nginx config. On our site, the object cache line appeared with the Redis drop-in active.

## Which caches does your site need?

Our measurements point to three caches to start with: a page cache, browser cache lifetimes and OPcache. An object cache and a CDN depend on your site. Whatever you add, switch on one layer at a time and test again after each, so you can tell which change helped:

| Your site | Cache layers to use first | Why, from our tests |
| --- | --- | --- |
| Blog or brochure site, visitors not logged in | Page cache, browser cache, OPcache | The page cache removed the server wait; OPcache cut our uncached test page from 203 ms to 54 ms |
| Members, courses, or a shop where users log in | Fix slow plugin work first; add an object cache if the database is on another server | Logged-in visits skipped the page cache (902 ms); Redis didn’t help with a local database |
| Database on a separate server (tested with a 1 ms simulated delay) | Object cache | 128 ms down to 61 ms with a 1 ms database delay |
| Visitors far from your server | Add a CDN | Not tested in our lab |

## How long each cache keeps things

Every cache trades freshness for speed, and each layer handles changes differently. We edited a post’s title with all three server caches running to see which ones noticed:

- **Object cache:** noticed straight away. An uncached request showed the new title at once, because WordPress clears the stored results for a post when the post changes.
- **Page cache:** didn’t notice. Our cached address kept serving the old title until we emptied the cache. Ours kept pages for 10 minutes (`fastcgi_cache_valid 200 301 10m`); plugins and hosts set their own lifetime.
- **Browser cache:** depends on the file name. WordPress added version strings to its scripts, such as `comment-reply.min.js?ver=7.1.3`, so a new version gets a new address and skips the stored copy. Images in the media library had no version string. With a 30-day lifetime, a browser that already has an image may keep showing the old one if you replace it under the same file name.

So a long browser lifetime suits files that change name when they change, and a page cache needs clearing whenever you publish an edit. Upload a changed image under a new file name rather than overwriting the old one.

## When caching causes problems

Caching causes problems when a cache keeps serving an old copy of a page after you’ve changed it. Our [guide to changes not showing](https://skybootstrap.com/wordpress-changes-not-showing/) shows how to find which cache is answering and clear it. Before and after any cache change, test the page logged out, as our speed testing guide explains.

## Frequently Asked Questions

### Is OPcache turned on by default?

PHP’s own default for `opcache.enable` is on, and it was on in our PHP 8.3.6 install (Ubuntu’s php8.3-fpm package). Your host can still turn it off or not load it, so check with them if you can’t see your PHP settings.

### Do I need a caching plugin if my host already caches pages?

You need one page cache, not two. Check the response headers of a logged-out page in your browser’s developer tools (Network tab), or look for “Page cache is detected” in Site Health. If the headers show a cache result like our `X-Cache: HIT`, a page cache is already working. Ask your host before adding a plugin on top.

### Does an object cache replace a page cache?

No. They cache different things. The page cache served a visitor in half a millisecond instead of 886 ms, while Redis only cut database trips, which mattered when the database was slow to reach.

## How we tested

We switched each cache layer on and off, one at a time, on a WordPress 7.1.3 test site on 3 November 2026. It ran Twenty Twenty-Five on nginx 1.24.0 with its fastcgi_cache page cache, PHP-FPM 8.3.6 with OPcache, MariaDB 10.11.14 and Redis 7.0.15. The object cache was the Redis Object Cache plugin 3.0.0 with the PHP redis extension 5.3.7.

To give the caches something to save, a small test plugin we wrote ran 60 random database queries and called a local service that waits 0.8 seconds. For the database on another server, a local proxy added 1 ms to each database message. Our nginx config added the `X-Cache` header and skipped the cache for logged-in visitors.

Server times are medians of 15 to 30 curl requests on the same machine, with 7 for the logged-in test and 3 rounds for cold versus warm cache. Scores are the median of three Lighthouse 12.8.2 mobile runs; for that test the plugin also added a full-size lazy main image, 1.1 MB of blocking CSS and JavaScript and a 2 MB autoloaded option. Compare the numbers with each other, not with your site. We didn’t test a CDN, caching plugins or Memcached.