PHPackages                             wyrihaximus/react-http-middleware-response-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. wyrihaximus/react-http-middleware-response-cache

ActiveLibrary[Caching](/categories/caching)

wyrihaximus/react-http-middleware-response-cache
================================================

Response caching middleware for @reactphp's HTTP server

3.1.0(6y ago)43.6k2[1 issues](https://github.com/WyriHaximus/reactphp-http-middleware-response-cache/issues)[3 PRs](https://github.com/WyriHaximus/reactphp-http-middleware-response-cache/pulls)1MITPHPPHP ^7.2CI failing

Since Nov 5Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/WyriHaximus/reactphp-http-middleware-response-cache)[ Packagist](https://packagist.org/packages/wyrihaximus/react-http-middleware-response-cache)[ RSS](/packages/wyrihaximus-react-http-middleware-response-cache/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (8)Versions (15)Used By (1)

Middleware that caches the response code and body of an URL list
================================================================

[](#middleware-that-caches-the-response-code-and-body-of-an-url-list)

[![Build Status](https://camo.githubusercontent.com/9d14e3dcea0d1186af0390801fcd457f80dd1ea4f1165da69327d6bbeae1154e/68747470733a2f2f7472617669732d63692e6f72672f57797269486178696d75732f72656163747068702d687474702d6d6964646c65776172652d726573706f6e73652d63616368652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/WyriHaximus/reactphp-http-middleware-response-cache)[![Latest Stable Version](https://camo.githubusercontent.com/ec55869545a5b3cee96a2bb74b2b23923acc7d6dac5787b833f6d0f74d3997c2/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d687474702d6d6964646c65776172652d726573706f6e73652d63616368652f762f737461626c652e706e67)](https://packagist.org/packages/WyriHaximus/react-http-middleware-response-cache)[![Total Downloads](https://camo.githubusercontent.com/b192b00ba85c19f28ba7cf8b1ceb4fe3d0bd1906c1f9216aaec2e8e342c29dc3/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d687474702d6d6964646c65776172652d726573706f6e73652d63616368652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/WyriHaximus/react-http-middleware-response-cache)[![Code Coverage](https://camo.githubusercontent.com/19551115ae254a2a7f2551eaa2096d4db3d33a4e4bb742c91a00fcbe5b8de821/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f57797269486178696d75732f72656163747068702d687474702d6d6964646c65776172652d726573706f6e73652d63616368652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-http-middleware-response-cache/?branch=master)[![License](https://camo.githubusercontent.com/15d4ef7405dad682769b49330ecdba695ee8f8bb215a8e8895f3e8c19b29b06f/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d687474702d6d6964646c65776172652d726573706f6e73652d63616368652f6c6963656e73652e706e67)](https://packagist.org/packages/WyriHaximus/react-http-middleware-response-cache)[![PHP 7 ready](https://camo.githubusercontent.com/4b7bfb418f7d3d31a42fa06b4694c5699ccc8bef4de2d9ee9f9db7cf58b5c331/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f57797269486178696d75732f72656163747068702d687474702d6d6964646c65776172652d726573706f6e73652d63616368652f62616467652e737667)](https://travis-ci.org/WyriHaximus/reactphp-http-middleware-response-cache)

Install
=======

[](#install)

To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.

```
composer require wyrihaximus/react-http-middleware-response-cache

```

This middleware caches the response code and body from a list of given URL's. Note that not headers will be cached at this point. The middleware accepts a cache configuration implementing `CacheConfigurationInterface`as first argument which will decide when to store something in the cache and what. As second argument it accepts a cache implementing [`CacheInterface`](https://reactphp.org/cache/#cacheinterface) so either [`ArrayCache`](https://reactphp.org/cache/#arraycache) shipping with [`react/cache`](https://reactphp.org/cache/)or any cache implementing [`CacheInterface`](https://reactphp.org/cache/#cacheinterface) from the [cache implementations](https://github.com/reactphp/react/wiki/Users#cache-implementations) listed at the [ReactPHP users wiki](https://github.com/reactphp/react/wiki/Users).

Usage
=====

[](#usage)

```
$server = new Server([
    /** Other middleware */
    new ResponseCacheMiddleware(
        new CacheConfiguration(
            [
                '/',
                '/robots.txt',
                '/favicon.ico',
                '/cache/***', // Anything that starts with /cache/ in the path will be cached
                '/api/???', // Anything that starts with /cache/ in the path will be cached (query is included in the cache key)
            ],
            [ // Optional, array with headers to include in the cache
                'Content-Type',
            ]
        ),
        new ArrayCache() // Optional, will default to ArrayCache but any CacheInterface cache will work.
    ),
    /** Other middleware */
]);
```

Sessions
========

[](#sessions)

Using this middleware together with [`wyrihaximus/react-http-middleware-session`](https://github.com/WyriHaximus/reactphp-http-middleware-session) then please take a look at [`wyrihaximus/react-http-middleware-response-cache-session-cache-configuration`](https://github.com/WyriHaximus/reactphp-http-middleware-response-cache-session-cache-configuration) to ensure you don't serve cached responses to users with active sessions.

License
=======

[](#license)

The MIT License (MIT)

Copyright (c) 2018 Cees-Jan Kiewiet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance40

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 65.1% 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.

###  Release Activity

Cadence

Every ~96 days

Recently: every ~116 days

Total

7

Last Release

2492d ago

Major Versions

1.2.1 → 2.0.02018-04-10

2.0.0 → 3.0.02018-09-03

PHP version history (3 changes)1.0.0PHP ^7.0

1.2.0PHP ^7.1

3.0.0PHP ^7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/147145?v=4)[Cees-Jan Kiewiet](/maintainers/WyriHaximus)[@WyriHaximus](https://github.com/WyriHaximus)

---

Top Contributors

[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (54 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (15 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (4 commits)")[![makeey](https://avatars.githubusercontent.com/u/23615966?v=4)](https://github.com/makeey "makeey (1 commits)")

---

Tags

cachehacktoberfesthttpmiddlewaremiddleware-cachesphpphp7reactphp

### Embed Badge

![Health badge](/badges/wyrihaximus-react-http-middleware-response-cache/health.svg)

```
[![Health](https://phpackages.com/badges/wyrihaximus-react-http-middleware-response-cache/health.svg)](https://phpackages.com/packages/wyrihaximus-react-http-middleware-response-cache)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

41.5k328.9k1](/packages/ccxt-ccxt)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k379.4k24](/packages/team-reflex-discord-php)[eliashaeussler/typo3-warming

Warming - Warms up Frontend caches based on an XML sitemap. Cache warmup can be triggered via TYPO3 backend or using a console command. Supports multiple languages and custom crawler implementations.

20229.9k](/packages/eliashaeussler-typo3-warming)[discord-php/http

Handles HTTP requests to Discord servers

25318.7k8](/packages/discord-php-http)

PHPackages © 2026

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