# Cache the WordPress REST API: 18 of 215 Sites Manage It, and None Used a Plugin

> We probed 215 WordPress sites whose homepage served a verified cache hit. 197 never served wp-json from cache. How to tell in two commands, and four fixes.

- Published: 2026-12-04
- Author: M Asif Rahman (https://ar.bd), Founder, WPDeveloper
- Tags: REST API, Caching, Headless, Tutorial, Performance, WordPress
- Canonical: https://xspeedcache.com/blog/cache-wordpress-rest-api/

---

Updated December 2026

On 4 December 2026 we probed 215 WordPress sites whose homepage served a verified cache hit, and 197 of them did not serve `/wp-json/wp/v2/posts?per_page=1` from cache. Only 18 did, and per our own header capture that day, not one of those 18 used a caching plugin. Your page cache is working. It was never pointed at your REST API, and in most plugins no setting will point it there. Here is how to tell in two commands, and the four fixes in the order worth doing.

## Quick Summary: What to Do, in Order

| If your situation is… | Do this | Why |
|:---|:---|:---|
| Slow block editor, mobile app or headless front end | Put an [object cache](https://xspeedcache.com/docs/object-cache/) behind WordPress first | Most REST cost is repeated queries, and this fixes them with no rules and no risk |
| Public, read-only routes only | Cache specific routes in your plugin, if it ships the setting | Precise and revocable, safe when the route is identical for everyone |
| You already run a CDN | Add an explicit edge cache rule for those routes | All 18 sites that managed it did so here |
| Routes you wrote yourself | Send `Cache-Control` from `rest_post_dispatch` | The only fix that travels with the code |
| Anything authenticated, personalised or writing | Leave it uncached | A shared cache can hand one caller's response to another |

## The Measurement: 215 Sites That All Had a Working Page Cache

We took 457 sites detected as WordPress from the public scan archive on xspeedcache.com. Each homepage was requested twice with a browser user agent, a second apart, and 235 returned a cache hit in their own headers the second time. Those 235 were then asked for `/wp-json/wp/v2/posts?per_page=1` the same way. 215 answered 200; the other 20 returned 401, 403, 404, 301, 500, 520 or nothing, and are excluded rather than counted as failures.

![Bar chart of 215 cached sites: 18 served wp-json from cache, 134 declared it uncacheable, 63 gave no evidence](https://xspeedcache.com/images/blog/wp-json-cache-breakdown.webp)

**Every one of the 18 hits was declared by an edge or server-level cache**, and **none by a caching plugin's own header**. Four of the 18 showed their plugin's hit header on the homepage and not on the REST route: the same software, the same site, the same minute, caching one URL and skipping the other.

A hit here means the second request was served from cache, which is what your second visitor gets. None of the 18 answered from an entry more than a second old, so this shows the route is cacheable and reused, not that it was already warm.

The sample is also biased toward sites running our own plugin, because it comes from our scanner's archive. That bias cannot explain the result, since no plugin of any brand served the route.

## Why Your Page Cache Skips wp-json

The intuitive answer is that WordPress forbids it. Read the source and that turns out to be false.

`WP_REST_Server::serve_request()` in WordPress 7.1.5 decides this in one line: `apply_filters( 'rest_send_nocache_headers', is_user_logged_in() )`, per the [`rest_send_nocache_headers` reference](https://developer.wordpress.org/reference/hooks/rest_send_nocache_headers/) on developer.wordpress.org. The default is `is_user_logged_in()`. For an anonymous caller, core sends no cache-prevention headers at all, which under [RFC 9111 §4.2](https://www.rfc-editor.org/rfc/rfc9111.html#section-4.2) leaves the response storable by a shared cache using heuristic freshness.

So the bypass is a decision made above WordPress, by the cache. Of the 134 sites that declared the route uncacheable, 46 sent a `cache-control` value byte-for-byte identical to core's own `wp_get_nocache_headers()` output, which core emits only when that filter returns true. The other 88 were refused by the plugin, the server or the edge. Those two causes have different fixes, which is why the check below reads the header rather than guessing.

## The Two-Request Check

Start with the free [xSpeed Scan](https://xspeedcache.com/scan/), which needs no account. In rubric 2026.10.1 it reports check **D2, "Page served from cache"** and **D5, "CDN edge serves the page"**. D2 passing is the precondition for everything here: it confirms your HTML really is cached. The scan does not fetch your REST route, so the second half is two commands you run yourself:

```bash
curl -sD - -o /dev/null https://example.com/
curl -sD - -o /dev/null https://example.com/wp-json/wp/v2/posts?per_page=1
```

Run each twice and read the second reply. Use a GET, never a HEAD: some caches will not answer a HEAD from cache, so it can report a miss on a cached route.

![Two curl panels on one site: the homepage returns a cache HIT, the REST route returns no-cache](https://xspeedcache.com/images/blog/wp-json-two-request-check.webp)

Compare the cache header, not the body. The ones that count are already set by your stack: `cf-cache-status`, `x-cache`, `x-cache-status`, `x-litespeed-cache`, `x-xspeed-cache`, `wpo-cache-status`. Our guide to [proving a cache is actually answering](https://xspeedcache.com/blog/check-wordpress-caching-working/) covers which of them prove nothing.

## What Caching It Is Actually Worth

![Paired first-byte bars: wp-json served from cache runs at 1.01x the homepage, uncached at 1.84x](https://xspeedcache.com/images/blog/wp-json-ttfb-paired.webp)

Because each site was measured against itself, a slow host cannot skew this. Where the route was served from cache it answered in **1.01×** its own homepage's time; where it was not, **1.84×**, or 1,039 ms against 534 ms. That gap is the editor save that stalls and the app screen that spins, and it is why [first-byte time on your HTML](https://xspeedcache.com/blog/reduce-ttfb-wordpress/) can look healthy while the application on top does not.

## Four Fixes, in the Order Worth Doing

### 1. Put an object cache behind WordPress

Do this first. It needs no route rules, carries no leak risk, and attacks the actual cost: the same queries running again on every call. Redis or Memcached in front of the database speeds up every route at once, including the authenticated ones you must never page-cache. Our walkthrough covers [a Redis object cache that survives a restart](https://xspeedcache.com/blog/setup-redis-object-cache-wordpress/).

### 2. Cache read-only routes in your plugin, if it ships the setting

Most do not. Read on the plugin directory on 4 December 2026:

| Plugin | Caches REST responses? | What it takes |
|:---|:---:|:---|
| xSpeed Cache | ✅ | Pro. Per-route rules with their own lifetimes, default TTL 5 minutes |
| W3 Total Cache 2.11.1 | ✅ | Pro. Listed as "REST API Caching" in its own feature list |
| WP-Optimize 4.7.2 | ✅ | Premium, listed as "Cache REST API requests" |
| LiteSpeed Cache 7.9.4 | ✅ | A LiteSpeed server, LiteSpeed hosting or QUIC.cloud, per its own requirements |
| WP Super Cache, WP Fastest Cache, Breeze, Cache Enabler, Surge | ❌ | No REST caching in the readme at all |
| Speed Optimizer (SiteGround) | ❌ | Its changelog records improving the cache *exclusion* for wp-json URLs |

Ours is one of four that ship it, and it sits behind Pro, which we would rather say plainly than bury. Our [feeds and REST API documentation](https://xspeedcache.com/docs/feeds-and-api/) gives the path: **xSpeed Cache → Cache → Advanced Cache → Feeds & API**. Set the default TTL to `0` so nothing is cached except routes you rule in by hand, then add `/wp/v2/posts*` at 10 to 30 minutes. Three guards hold whatever you type: authenticated requests, write methods and our own admin routes are never stored.

If you are not buying anything, skip the rest of this section. The next two fixes are free, and they are what the 18 sites actually used.

### 3. Cache it at the edge

This is the one that worked in the field. Cloudflare reports `cf-cache-status: DYNAMIC` on `/wp-json/` because its default rules cache static assets, not JSON. A [cache rule](https://developers.cloudflare.com/cache/how-to/cache-rules/) matching one specific read-only path, with an edge TTL you choose, changes that. Scope it to that path, never to `/wp-json/*`, which sweeps in authenticated and Store API traffic.

### 4. Send Cache-Control from routes you wrote

For your own endpoints, `rest_post_dispatch` lets the response carry its own policy, per the [REST API handbook](https://developer.wordpress.org/rest-api/):

```php
add_filter( 'rest_post_dispatch', function ( $response, $server, $request ) {
    if ( 'GET' === $request->get_method()
         && ! is_user_logged_in()
         && str_starts_with( $request->get_route(), '/my-plugin/v1/public' ) ) {
        $response->header( 'Cache-Control', 'public, max-age=300' );
    }
    return $response;
}, 10, 3 );
```

The route test and the `is_user_logged_in()` test are both load-bearing. Drop either and you are telling shared caches to store responses that may differ per caller. Vendors keep shipping fixes for exactly this: W3 Total Cache 2.11.1, released 26 November 2026, added "skip shared caching for session-bound responses and WooCommerce Store API requests", and LiteSpeed Cache 7.9 disabled REST caching for Divi 5 to fix an `invalid_nonce` failure. If you run a store, read [what to exclude and why](https://xspeedcache.com/blog/wordpress-cache-exclusions-setup/) first, and treat the [WooCommerce](https://xspeedcache.com/use-cases/woocommerce/) Store API as never-cache.

## Checking Forty Sites Instead of One

On one site this is a ten-second check. On forty it is the thing nobody does, which is why the condition is so common. Run it at handover and after any cache or CDN change: a route that was cached can stop being cached when a rule is reordered. Our [cache rules and bypass documentation](https://xspeedcache.com/docs/rules-and-bypass/) covers the ordering, and [Free vs Pro](https://xspeedcache.com/free-vs-pro/) says which side of the line each feature sits on. xSpeed Cache is ours, built by WPDeveloper; it reads 1.5.0 with 10,000+ installs and 5.0 from 29 ratings on the plugin directory as of 4 December 2026.

## Five Ways This Goes Wrong

| The mistake | What it costs you |
|:---|:---|
| Caching `/wp-json/*` wholesale | 🚫 That namespace holds authenticated routes, writes and the Store API |
| Trusting a HEAD request | A miss reported on a route that is cached perfectly well |
| Reading the body instead of the header | JSON looks identical from cache and from PHP |
| Forcing `rest_send_nocache_headers` to false globally | Strips the protection from logged-in responses too |
| Assuming a passing homepage check covers everything | It covers the homepage, nothing else |

## Frequently Asked Questions

### I turned on my plugin's cache and wp-json is still slow. What did I miss?
Probably nothing. Most caching plugins do not cache REST responses at all, and the four that do want Pro, Premium or a particular server first.

### My homepage shows a cache hit but wp-json shows no cache header at all. Is that broken?
No. 63 of the 215 carried no cache evidence either way. No layer claimed the route, which usually means PHP answered it.

### Does WordPress stop caches from storing REST responses?
Not for anonymous callers. Core sends no-cache headers on a REST response only when `rest_send_nocache_headers` returns true, which defaults to whether the user is logged in.

### I see `cache-control: no-cache, must-revalidate, max-age=0, no-store, private` on an anonymous request. Where is that from?
That is core's own `wp_get_nocache_headers()` string, so something on your site returns true from that filter for anonymous callers. 46 of the sites probed were in this state.

### Is it safe to cache `/wp/v2/posts`?
For a public blog, usually: it returns the same published posts to everyone. Check first that no plugin adds per-user fields.

### I cached a route and a logged-in user saw someone else's data. What went wrong?
A shared cache stored a response that varied per caller. Cache only routes identical for everyone, and test as two logged-in users.

### Will an object cache alone fix my slow REST API?
Often, and it is the safest thing to try: it cuts repeated query cost without storing a response.

### Does Cloudflare cache wp-json by default?
No. It reports `cf-cache-status: DYNAMIC`, meaning its default rules did not consider that path cacheable.

### My REST route got slower after I added an edge rule. Why?
A rule that matches but sets a very short TTL adds a round trip without ever serving a hit. Check the `age` header on a second request.

### How long should the TTL be?
Short enough that stale content does not matter: 5 to 30 minutes for a posts listing, an hour for media and pages.

### Can I just exclude wp-json and forget it?
That is what most stacks already do: it is the state described above.

## Your Next Four Steps

**Do these four things, in this order:**

1. Run the two commands above and compare the second reply of each.
2. If the homepage is not cached either, start there: [why only the homepage caches](https://xspeedcache.com/blog/only-homepage-cached/) has the usual cause.
3. Put an object cache behind WordPress: the one fix with no rules to get wrong.
4. If you run a CDN, add a cache rule for one read-only route, then re-run the check.

Run the free scan on your own site: [xspeedcache.com/scan/](https://xspeedcache.com/scan/)

If you want route rules in the plugin rather than at the edge, that is xSpeed Cache Pro, from $29 a year at the founding price with a 14-day money-back guarantee. The object cache and the edge rule cost nothing, and they are what our sample actually used.
