PHPackages                             airesvsg/wp-rest-api-cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. airesvsg/wp-rest-api-cache

ActiveWordpress-plugin[Caching](/categories/caching)

airesvsg/wp-rest-api-cache
==========================

Enable caching for WordPress REST API and increase speed of your application.

24339136[9 issues](https://github.com/airesvsg/wp-rest-api-cache/issues)[1 PRs](https://github.com/airesvsg/wp-rest-api-cache/pulls)PHP

Since Feb 28Pushed 7y ago9 watchersCompare

[ Source](https://github.com/airesvsg/wp-rest-api-cache)[ Packagist](https://packagist.org/packages/airesvsg/wp-rest-api-cache)[ RSS](/packages/airesvsg-wp-rest-api-cache/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

WP REST API Cache
=================

[](#wp-rest-api-cache)

Enable caching for WordPress REST API and increase speed of your application

- [Installation](#installation)
- [Filters](#filters)
- [How to use filters](#how-to-use-filters)

Installation
============

[](#installation)

1. Copy the `wp-rest-api-cache` folder into your `wp-content/plugins` folder
2. Activate the `WP REST API Cache` plugin via the plugin admin page

Filters
=======

[](#filters)

FilterArgument(s)rest\_cache\_headersarray **$headers**
string **$request\_uri**
WP\_REST\_Server **$server**
WP\_REST\_Request **$request**rest\_cache\_skipboolean **$skip** ( default: WP\_DEBUG )
string **$request\_uri**
WP\_REST\_Server **$server**
WP\_REST\_Request **$request**rest\_cache\_keystring **$request\_uri**
WP\_REST\_Server **$server**
WP\_REST\_Request **$request**rest\_cache\_timeoutint **$timeout**
int **$length**
int **$period**rest\_cache\_update\_optionsarray **$options**rest\_cache\_get\_optionsarray **$options**rest\_cache\_show\_adminboolean **$show**rest\_cache\_show\_admin\_menuboolean **$show**rest\_cache\_show\_admin\_bar\_menuboolean **$show**How to use filters
------------------

[](#how-to-use-filters)

- **sending headers**

```
add_filter( 'rest_cache_headers', function( $headers ) {
	$headers['Cache-Control'] = 'public, max-age=3600';

	return $headers;
} );
```

- **changing the cache timeout**

```
add_filter( 'rest_cache_timeout', function() {
	// https://codex.wordpress.org/Transients_API#Using_Time_Constants
	return 15 * DAY_IN_SECONDS;
} );
```

or

```
add_filter( 'rest_cache_get_options', function( $options ) {
	if ( ! isset( $options['timeout'] ) ) {
		$options['timeout'] = array();
	}

	// https://codex.wordpress.org/Transients_API#Using_Time_Constants
	$options['timeout']['length'] = 15;
	$options['timeout']['period'] = DAY_IN_SECONDS;

	return $options;
} );
```

- **skipping cache**

```
add_filter( 'rest_cache_skip', function( $skip, $request_uri ) {
	if ( ! $skip && false !== stripos( $request_uri, 'wp-json/acf/v2' ) ) {
		return true;
	}

	return $skip;
}, 10, 2 );
```

- **show / hide admin links**

[![WP REST API Cache](https://camo.githubusercontent.com/41d30e291c0872c859477fd7d35f23ee2a5a69f0e917e9ed5dec7df42e7463b4/687474703a2f2f6169726573676f6e63616c7665732e636f6d2e62722f73637265656e73686f742f77702d726573742d6170692d63616368652f726561646d652f66696c7465722d61646d696e2d73686f772e676966)](https://camo.githubusercontent.com/41d30e291c0872c859477fd7d35f23ee2a5a69f0e917e9ed5dec7df42e7463b4/687474703a2f2f6169726573676f6e63616c7665732e636f6d2e62722f73637265656e73686f742f77702d726573742d6170692d63616368652f726561646d652f66696c7465722d61646d696e2d73686f772e676966)

- **empty cache on post-save**

You can use the wordpress default filter "save\_post" if you like to empty the cache on every save of a post, page or custom post type.

```
add_action( 'save_post', function( $post_id ) {
  if ( class_exists( 'WP_REST_Cache' ) ) {
    WP_REST_Cache::empty_cache();
  }
} );
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/396668?v=4)[Aires Gonçalves](/maintainers/airesvsg)[@airesvsg](https://github.com/airesvsg)

---

Top Contributors

[![airesvsg](https://avatars.githubusercontent.com/u/396668?v=4)](https://github.com/airesvsg "airesvsg (10 commits)")[![jpylisela](https://avatars.githubusercontent.com/u/2624330?v=4)](https://github.com/jpylisela "jpylisela (1 commits)")[![stephanedemotte](https://avatars.githubusercontent.com/u/2158130?v=4)](https://github.com/stephanedemotte "stephanedemotte (1 commits)")[![vollyimnetz](https://avatars.githubusercontent.com/u/6512765?v=4)](https://github.com/vollyimnetz "vollyimnetz (1 commits)")

---

Tags

apicacherestrest-apiwordpresswp

### Embed Badge

![Health badge](/badges/airesvsg-wp-rest-api-cache/health.svg)

```
[![Health](https://phpackages.com/badges/airesvsg-wp-rest-api-cache/health.svg)](https://phpackages.com/packages/airesvsg-wp-rest-api-cache)
```

###  Alternatives

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
