Title: WP REST Cache
Author: Acato
Published: <strong>January 31, 2019</strong>
Last modified: November 30, 2026

---

Search plugins

![](https://ps.w.org/wp-rest-cache/assets/banner-772x250.png?rev=3328849)

![](https://ps.w.org/wp-rest-cache/assets/icon-256x256.png?rev=3328849)

# WP REST Cache

 By [Acato](https://profiles.wordpress.org/acato/)

[Download](https://downloads.wordpress.org/plugin/wp-rest-cache.2026.4.5.zip)

 * [Details](https://wordpress.org/plugins/wp-rest-cache/#description)
 * [Reviews](https://wordpress.org/plugins/wp-rest-cache/#reviews)
 * [Development](https://wordpress.org/plugins/wp-rest-cache/#developers)

 [Support](https://wordpress.org/support/plugin/wp-rest-cache/)

## Description

Are you facing speed issues, using the WordPress REST API? This plugin will allow
WordPress to cache the responses of the REST API, making it much faster.

This plugin offers:

 * Caching of all default WordPress REST API `GET`-endpoints.
 * Caching of (custom) post type endpoints.
 * Caching of (custom) taxonomy endpoints.
 * Automated flushing of caches if (some of) its contents are edited.
 * Manual flushing of all caches.
 * Manual flushing of specific caches.
 * A counter how many times a cache has been retrieved.
 * Specifying after what time the cache should be timed out.
 * Registering custom endpoints for caching.
 * Automatic cache regeneration.

**WP REST Cache Pro**
 For more advanced features, check out our [WP REST Cache Pro](https://plugins.acato.nl/)
plugin:

 * Configure custom endpoints for caching through the wp-admin interface.
 * Configure relationships within endpoints.
 * No coding required.

### Installation from within WordPress

 1. Visit ‘Plugins > Add New’ (or ‘My Sites > Network Admin > Plugins > Add New’ if
    you are on a multisite installation).
 2. Search for ‘WP REST Cache’.
 3. Activate the WP REST Cache plugin through the ‘Plugins’ menu in WordPress.
 4. Go to “after activation” below.

### Installation manually

 1. Upload the `wp-rest-cache` folder to the `/wp-content/plugins/` directory.
 2. Activate the WP REST Cache plugin through the ‘Plugins’ menu in WordPress.
 3. Go to “after activation” below.

### After activation

 1. Visit ‘Plugins > Must-Use’ (or ‘My Sites > Network Admin > Plugins > Must-Use’ 
    if you are on a multisite installation).
 2. Check if the ‘WP REST Cache – Must-Use Plugin’ is there, if not copy the file `
    wp-rest-cache.php` from the `/sources` folder of the WP REST Cache Plugin to the
    folder `/wp-content/mu-plugins/`.

**Optionally:**
 The default timeout for caches generated by the WP REST Cache plugin
is set to 1 year. If you want to change this:

 1. Visit ‘Settings > WP REST Cache’.
 2. Change the Cache timeout.

## Screenshots

[⌊Settings for the WP REST Cache plugin.⌉⌊Settings for the WP REST Cache plugin.⌉[

Settings for the WP REST Cache plugin.

[⌊An overview of cached endpoint calls.⌉⌊An overview of cached endpoint calls.⌉[

An overview of cached endpoint calls.

[⌊An overview of cached single items.⌉⌊An overview of cached single items.⌉[

An overview of cached single items.

[⌊Cache details page - Cache info.⌉⌊Cache details page - Cache info.⌉[

Cache details page – Cache info.

[⌊Cache details page - Cache data.⌉⌊Cache details page - Cache data.⌉[

Cache details page – Cache data.

## FAQ

### I have edited a page/post, do I need to clear the cache?

No, the plugin will automatically flush all cache related to the page/post you just
edited.

### I have created a custom post type, will the plugin cache the custom post type endpoint?

Yes, the plugin will automatically cache the endpoint of custom post types. Unless
you have created a custom WP_REST_Controller for it, then it will not automatically
cache the endpoint.

### I have created a custom taxonomy, will the plugin cache the taxonomy endpoint?

Yes, the plugin will automatically cache the endpoint of custom taxonomies. Unless
you have created a custom WP_REST_Controller for it, then it will not automatically
cache the endpoint.

### I have created a custom WP REST endpoint, will the plugin cache this endpoint?

No, the plugin will not cache your custom endpoint unless you tell it to cache it
using our [WP REST Cache Pro](https://plugins.acato.nl/) plugin or the hook `wp_rest_cache/
allowed_endpoints` (See ‘Can I register my own endpoint for caching?’). Please keep
in mind that once you do so the plugin will not automatically flush the cache of
that endpoint if something is edited (it has no way of knowing when to flush the
cache). It will however try to determine the relations and for the determined relations
it will flush the cache automatically once the relation is edited.

### Can I register my own endpoint for caching?

Yes you can! You can use our [WP REST Cache Pro](https://plugins.acato.nl/) plugin
to easily register your own endpoints for caching through the wp-admin interface.
Or you can do it programmatically by using the hook `wp_rest_cache/allowed_endpoints`
like this:

    ```
    /**
     * Register the /wp-json/acf/v3/posts endpoint so it will be cached.
     */
    function wprc_add_acf_posts_endpoint( $allowed_endpoints ) {
        if ( ! isset( $allowed_endpoints[ 'acf/v3' ] ) || ! in_array( 'posts', $allowed_endpoints[ 'acf/v3' ] ) ) {
            $allowed_endpoints[ 'acf/v3' ][] = 'posts';
        }
        return $allowed_endpoints;
    }
    add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_add_acf_posts_endpoint', 10, 1);
    ```

_Please note:_ the WP REST Cache plugin will try to detect relations in the cached
data to automatically flush the cache when related items are edited, but this detection
is not flawless so your caches might not be flushed automatically.

### Can I unregister an endpoint so it is no longer cached?

Yes you can! Use the hook `wp_rest_cache/allowed_endpoints` like this:

    ```
    /**
     * Unregister the /wp-json/wp/v2/comments endpoint so it will not be cached.
     */
    function wprc_unregister_wp_comments_endpoint( $allowed_endpoints ) {
        if ( isset( $allowed_endpoints[ 'wp/v2' ] ) && ( $key = array_search( 'comments', $allowed_endpoints[ 'wp/v2' ] ) ) !== false ) {
            unset( $allowed_endpoints[ 'wp/v2' ][ $key ] );
        }
        return $allowed_endpoints;
    }
    add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_unregister_wp_comments_endpoint', 100, 1);
    ```

### Can I force a call to the REST API to not use caching?

Yes you can! Add the GET-parameter `skip_cache=1` to your call and no caching will
be used.

### On the cache overview page I see the object type is ‘unknown’. Can I help the WP REST Cache plugin to detect the object type correctly?

Yes you can! Use the hook `wp_rest_cache/determine_object_type` like this:

    ```
    function wprc_determine_object_type( $object_type, $cache_key, $data, $uri ) {
        if ( $object_type !== 'unknown' || strpos( $uri, $your_namespace . '/' . $your_rest_base ) === false ) {
            return $object_type;
        }
        // Do your magic here
        $object_type = 'website';
        // Do your magic here
        return $object_type;
    }
    add_filter( 'wp_rest_cache/determine_object_type', 'wprc_determine_object_type', 10, 4 );
    ```

### Can expired caches be automatically regenerated?

Yes they can! Go to Settings > WP REST Cache, on the Settings tab you can check `
Enable cache regeneration`, this will activate a cron job which will check if there
are any expired (or flushed) caches and regenerate them. Using the `Regeneration
interval` you can determine how often this regeneration process should run. The `
Max number regenerate caches` limits the number of regenerated caches per regeneration
process, this is so your server doesn’t get flooded with the regeneration calls.

### Are expired caches removed from the database?

Yes. Once a day a cron job removes caches from the database that expired more than
a day ago, or that were flushed and already cleaned up. This only happens when cache
regeneration is disabled, because the regeneration needs these caches to know what
to regenerate. Use the filter `wp_rest_cache/purge_stale_caches` to override this,`
wp_rest_cache/stale_cache_grace_period` to change how long (in seconds) an expired
cache is kept and `wp_rest_cache/max_purge_caches` to change the number of caches
removed per run (default 1000).

### Can I hide the ‘Clear REST cache’ in the wp-admin bar?

Yes you can! Use the hook `wp_rest_cache/display_clear_cache_button` like this:

    ```
    function wprc_display_clear_cache_button( $show ) {
        return false;
    }
    add_filter('wp_rest_cache/display_clear_cache_button', 'wprc_display_clear_cache_button', 10, 1);
    ```

### Can I differentiate between caches based upon request headers?

Yes you can! There are two options for this: 1. Go to Settings > WP REST Cache and
add `Global cacheable request headers`. This is a comma seperated list. These headers
will be used for ALL endpoints. 2. Use the hook `wp_rest_cache/cacheable_request_headers`
to specify per endpoint which request headers should be used. Like this:

    ```
    function wprc_add_cacheable_request_headers( $cacheable_headers ) {
        $cacheable_headers['wp/v2/posts'] = 'LANG';
        return $cacheable_headers;
    }
    add_filter('wp_rest_cache/cacheable_request_headers', 'wprc_add_cacheable_request_headers', 10, 1);
    ```

### Since version 2026.4.0 my REST requests are no longer cached. Why?

Requests with an `Authorization` header or HTTP authentication (e.g. Application
Passwords, Basic auth or JWT) and responses generated for a logged-in user are no
longer cached, so a response meant for one user is never served to another. If your
front end (e.g. a headless site) sends the same credentials with every request, 
go to Settings > WP REST Cache and add `Authorization` to the `Global cacheable 
request headers`: every set of credentials then gets its own cache. This also works
when your web server handles the Basic authentication.

Please note: the header value (e.g. the Basic auth credentials) is then stored in
the database with each cache, because cache regeneration needs it to repeat the 
request. It is masked in the wp-admin. If the header isn’t needed for WordPress,
removing it from the requests is the best option.

For responses generated for a logged-in user, use the filter `wp_rest_cache/cache_authenticated_response`
to allow caching, but only when the responses are the same for every user or the
cache key is made user specific (e.g. with the filter `wp_rest_cache/cache_key`).

### Can I change which users can change the settings and flush caches?

Yes you can! Use the hook `wp_rest_cache/settings_capability` like this:

    ```
    function wprc_change_settings_capability( $capability ) {
        // Change the capability to users who can edit posts.
        return 'edit_posts';
    }
    add_filter('wp_rest_cache/settings_capability', 'wprc_change_settings_capability', 10, 1);
    ```

### Can I use WP CLI to flush caches from the command line?

Yes you can! Use the `wp wp-rest-cache flush` command to flush caches. Type `wp 
wp-rest-cache flush --help` to see all options.

### Is Redis Object Cache supported?

We are using the WordPress transient API, so as long as you are using a Redis Object
Cache plugin which enables Redis caching through the transients API it is supported.

### How can I report security bugs?

You can report security bugs through the Patchstack Vulnerability Disclosure Program.
The Patchstack team helps validate, triage and handle any security vulnerabilities.
[Report a security vulnerability.](https://patchstack.com/database/vdp/1307d9dc-155a-4a70-b80c-978a2832290f)

## Reviews

![](https://secure.gravatar.com/avatar/63e470dd6139c104a2624af36c2eb17436d7d8b1388179c75de96d4b0ff6802d?
s=60&d=retro&r=g)

### 󠀁[Does the job](https://wordpress.org/support/topic/does-the-job-1068/)󠁿

 [vlaim](https://profiles.wordpress.org/vlaim/) October 1, 2025

Nice one! Decreased response time by almost 60%.

![](https://secure.gravatar.com/avatar/0efcf569b75907e074af231a470399d789f2e49a5dd2f2cfc3213c128a794151?
s=60&d=retro&r=g)

### 󠀁[Absolutely fantastic!](https://wordpress.org/support/topic/absolutely-fantastic-110/)󠁿

 [zerfl](https://profiles.wordpress.org/zerfl/) August 28, 2025 1 reply

This plugin is excellent and works exactly as advertised. Definitely worth a perfect
rating. I do think the FAQ could be expanded a little more to mention process_cache_relations
for custom REST endpoints, however. I only found my solution buried in other users'
threads. I had wrongly assumed that providing the object type manually via the determine_object_type
hook was equivalent to making object relationships work, which is clearly not the
case. Overall, a really great plugin and very well thought-out.

![](https://secure.gravatar.com/avatar/2507a260105b9c3b03ee6c14c8e2672c370b2d95687e5ccabb0c1b0d15c20b73?
s=60&d=retro&r=g)

### 󠀁[Works great but honestly it could be so much better](https://wordpress.org/support/topic/works-great-but-honestly-it-could-be-so-much-better/)󠁿

 [hirngesicht](https://profiles.wordpress.org/hirngesicht/) April 11, 2025 4 replies

Using this plugin has made my API for filtering products go from finishing the filtering
and reaching the user in 2.3 seconds to reaching the user in about 200 ms. A huge
improvement indeed. However, I've noticed two things that slowly drive me insane:
The add_filter for hiding the REST API button in the admin panel isn't working. 
Why does this need a filter at all? Just make it a setting. I don't get it. There
is a serious lack of settings for this plugin. What if I want to cache one API route
shorter than another? That's currently impossible. Where's the "regenerate all caches"
button? This might very well be the only caching plugin without such a button. Yes,
it has a "Clear all", but no "Regenerate all". This is a solid 5/5 if they add the
above. I've yet to find a better solution that doesn't involve Cloudflare. Thanks
for the plugin!

![](https://secure.gravatar.com/avatar/90bc62f72eef4e45db8fae09f4d124c89b2408b827b2f6ad77dd007470b762af?
s=60&d=retro&r=g)

### 󠀁[Wroks good with WP Maps](https://wordpress.org/support/topic/wroks-good-with-wp-maps/)󠁿

 [carnini](https://profiles.wordpress.org/carnini/) June 24, 2024

Installed on suggestion of WP Maps, made a big difference in load speeds of maps.

![](https://secure.gravatar.com/avatar/ad90cef47f18eec2a5e174ddac9db895a74d428b000a748c1d4c3dde93a13bff?
s=60&d=retro&r=g)

### 󠀁[Works well with headless WordPress and Nuxt 3](https://wordpress.org/support/topic/works-well-with-headless-wordpress-and-nuxt-3/)󠁿

 [thaikolja](https://profiles.wordpress.org/thaikolja/) April 28, 2024

Great plugin! I use it for a headless WordPress instance with Nuxt 3, and it works
perfectly fine. The only thing I needed to change was the API endpoint since I created
a custom endpoint to the route. But the FAQ cleared this up quickly and it works
flawlessly. As a small suggestion I'd propose to add this option to the plugin's
settings page for easier access.

![](https://secure.gravatar.com/avatar/e052969b1253404a46573b8f096cc09ff6050d7f98c4e81bf1f248283c1a5896?
s=60&d=retro&r=g)

### 󠀁[Best support I’ve ever gotten!](https://wordpress.org/support/topic/best-support-ive-ever-gotten/)󠁿

 [katerlouis](https://profiles.wordpress.org/katerlouis/) March 12, 2024

It's been years since I touched wordpress or php. My usecase was very tricky and
not doable out of the box. It worked out great in the end and the response time 
is now 4-5 times quicker. Amazing. But the best part is how quickly Richard answered
to my noob questions and even fixed a bug I found. If you ever need a beta tester!
Hit me up <3

 [ Read all 42 reviews ](https://wordpress.org/support/plugin/wp-rest-cache/reviews/)

## Contributors & Developers

“WP REST Cache” is open source software. The following people have contributed to
this plugin.

Contributors

 *   [ Acato ](https://profiles.wordpress.org/acato/)
 *   [ Richard Korthuis ](https://profiles.wordpress.org/rockfire/)
 *   [ yoeridekker ](https://profiles.wordpress.org/yoeridekker/)

“WP REST Cache” has been translated into 6 locales. Thank you to [the translators](https://translate.wordpress.org/projects/wp-plugins/wp-rest-cache/contributors)
for their contributions.

[Translate “WP REST Cache” into your language.](https://translate.wordpress.org/projects/wp-plugins/wp-rest-cache)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/wp-rest-cache/), check
out the [SVN repository](https://plugins.svn.wordpress.org/wp-rest-cache/), or subscribe
to the [development log](https://plugins.trac.wordpress.org/log/wp-rest-cache/) 
by [RSS](https://plugins.trac.wordpress.org/log/wp-rest-cache/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 2026.4.5

Release Date: November 30th, 2026

Security: Unauthenticated visitors could poison the cache with a query string that
WordPress core reads differently than the cache key: the home URL was removed anywhere
in the request URI (also inside parameter names and values) and bytes removed by
URL sanitization were dropped from the cache key only. The home URL is now only 
removed from the start of the request URI, and requests whose query string does 
not match the cache key are no longer cached. It was reported by Kang MinSeok (AhnLab)
through Patchstack. All existing caches are flushed on update.
 Improvement: Responses
without a `type` field (e.g. limited with `_fields`) now get the post type or taxonomy
of the requested route as object type, so they are flushed when content of that 
type changes.

#### 2026.4.4

Release Date: November 26th, 2026

Feature: Show an admin notice when many REST requests aren’t cached because they
carry credentials (e.g. an `Authorization` header or HTTP authentication), explaining
how to cache them. Added filters `wp_rest_cache/credential_skips_notice_threshold`
and `wp_rest_cache/credential_skips_sample_rate`.
 Improvement: When `Authorization`
is a cacheable request header, requests where the web server handles the Basic authentication
are now cached per set of credentials as well. Improvement: Stored credentials in
the `Authorization` and `Proxy-Authorization` request headers are masked in the 
wp-admin. Improvement: Added a FAQ item on why REST requests are no longer cached
since version 2026.4.0. Fix: Typo in the plugin (de)activation notices.

#### 2026.4.3

Release Date: November 23rd, 2026

Security: Unauthenticated visitors could poison the cache by sending a GET request
with a request body (e.g. a JSON body) or a method override (`_method` parameter
or `X-HTTP-Method-Override` header). WordPress core uses these to generate the response,
but they were not part of the cache key, so the response was served to all visitors
of that URL. It was reported by Kang MinSeok (AhnLab) through Patchstack. All existing
caches are flushed on update.
 Backwards compatibility: GET and HEAD requests with
a request body, and requests with a method override, are no longer cached. For other
request methods that are allowed to be cached (setting “Allowed request methods”)
the request body is now part of the cache key, so requests with a different body
no longer share a cache. The cache key of requests without a body is unchanged. 
The `Endpoint_Api::save_cache()` method now accepts the optional `$server` and `
$request` arguments of the `rest_pre_echo_response` filter. Feature: Added filter`
wp_rest_cache/skip_get_request_with_body` to allow caching of GET and HEAD requests
with a request body (cached per body).

#### 2026.4.2

Release Date: October 29th, 2026

Fix: Caches that expired, or that were flushed and cleaned up, were never removed
from the database, causing the caches table to grow indefinitely. A daily cron job
now removes them (unless cache regeneration is enabled). It was reported by krstarica.

Improvement: The cache regeneration cron no longer loads the entire caches table
into memory. Feature: Added filters `wp_rest_cache/purge_stale_caches`, `wp_rest_cache/
stale_cache_grace_period` and `wp_rest_cache/max_purge_caches`.

#### 2026.4.1

Release Date: October 29th, 2026

Fix: Deleted caches that had been flushed and cleaned up before were never removed
from the database, causing the caches table to grow indefinitely. Existing leftover
caches are removed by the cleanup cron. It was reported by krstarica.

#### 2026.4.0

Release Date: October 27th, 2026

Security: Responses generated for authenticated users (e.g. through Application 
Passwords or Basic auth) could be cached and served to unauthenticated visitors.
Requests with an Authorization header and requests with context=edit are no longer
cached, responses for authenticated users are only cached if the cache key is user
specific, and nonce cached requests are now cached per session. All existing caches
are flushed on update.
 Feature: Added filter `wp_rest_cache/cache_authenticated_response`
to allow caching of responses generated for authenticated users when the cache key
is made user specific.

#### 2026.3.1

Release Date: July 25th, 2026

Improvement: Make the mu-plugin use the same version as the main plugin.

#### 2026.3.0

Release Date: July 24th, 2026

Fix: several small fixes and improvements.
 Improvement: Add support for using regex
inside wp_rest_cache/allowed_endpoints and wp_rest_cache/disallowed_endpoints filters.

#### 2026.2.0

Release Date: May 19th, 2026

Fix: specified key was too long error.
 Improvement: Extra filters and actions.

#### 2026.1.3

Release Date: March 3rd, 2026

Fix: Prevent performance issue with hierarchical categories.

#### 2026.1.2

Release Date: February 25th, 2026

Fix: Prevent PHP warnings.
 Improvement: Add filter to disallow skip_cache parameter.
Improvement: Added error log if set_transient fails. Improvement: Add support for
flushing term cache when objects terms are modified. (Contribution by: Moshe Gross)

#### 2026.1.1

Release Date: January 20th, 2026

Fix: A XSS vulnerability in the plugin was discovered and fixed. It was reported
by Nguyen Ba Khanh.
 Fix: Improved transition_post_status_logic. (Contribution by:
Moshe Gross)

#### 2026.1.0

Release Date: January 14th, 2026

Improvement: Only flush caches on meta update if filter returns true.

#### 2025.2.0

Release Date: December 15th, 2025

Improvement: Also flush caches when only the (post) meta is updated.

#### Earlier versions

For the changelog of earlier versions, please refer to [the changelog on Github](https://github.com/acato-plugins/wp-rest-cache/blob/master/changelog.md).

## Meta

 *  Version **2026.4.5**
 *  Last updated **5 days ago**
 *  Active installations **10,000+**
 *  WordPress version ** 4.7 or higher **
 *  Tested up to **7.0.9**
 *  PHP version ** 7.0 or higher **
 *  Languages
 * [Catalan](https://ca.wordpress.org/plugins/wp-rest-cache/), [Chinese (China)](https://cn.wordpress.org/plugins/wp-rest-cache/),
   [Dutch](https://nl.wordpress.org/plugins/wp-rest-cache/), [English (US)](https://wordpress.org/plugins/wp-rest-cache/),
   [German](https://de.wordpress.org/plugins/wp-rest-cache/), [Korean](https://ko.wordpress.org/plugins/wp-rest-cache/),
   and [Russian](https://ru.wordpress.org/plugins/wp-rest-cache/).
 *  [Translate into your language](https://translate.wordpress.org/projects/wp-plugins/wp-rest-cache)
 * Tags
 * [api](https://wordpress.org/plugins/tags/api/)[cache](https://wordpress.org/plugins/tags/cache/)
   [rest](https://wordpress.org/plugins/tags/rest/)[rest cache](https://wordpress.org/plugins/tags/rest-cache/)
   [wp-rest-api](https://wordpress.org/plugins/tags/wp-rest-api/)
 *  [Advanced View](https://wordpress.org/plugins/wp-rest-cache/advanced/)

## Ratings

 4.9 out of 5 stars.

 *  [  38 5-star reviews     ](https://wordpress.org/support/plugin/wp-rest-cache/reviews/?filter=5)
 *  [  3 4-star reviews     ](https://wordpress.org/support/plugin/wp-rest-cache/reviews/?filter=4)
 *  [  1 3-star review     ](https://wordpress.org/support/plugin/wp-rest-cache/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/wp-rest-cache/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/wp-rest-cache/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/wp-rest-cache/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/wp-rest-cache/reviews/)

## Contributors

 *   [ Acato ](https://profiles.wordpress.org/acato/)
 *   [ Richard Korthuis ](https://profiles.wordpress.org/rockfire/)
 *   [ yoeridekker ](https://profiles.wordpress.org/yoeridekker/)

## Support

Issues resolved in last two months:

     2 out of 2

 [View support forum](https://wordpress.org/support/plugin/wp-rest-cache/)