PHPackages                             wpjscc/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. [HTTP &amp; Networking](/categories/http)
4. /
5. wpjscc/react-http-middleware-response-cache

ActiveLibrary[HTTP &amp; Networking](/categories/http)

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

Response caching middleware for @reactphp's HTTP server

v1.0.0(2y ago)05MITPHPPHP &gt;=8.2

Since Nov 2Pushed 2y agoCompare

[ Source](https://github.com/wpjscc/reactphp-http-middleware-response-cache)[ Packagist](https://packagist.org/packages/wpjscc/react-http-middleware-response-cache)[ GitHub Sponsors](https://github.com/WyriHaximus)[ RSS](/packages/wpjscc-react-http-middleware-response-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

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 wpjscc/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.
        null,
        [
            'stream_support' => true,
        ]
    ),
    /** 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

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

928d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76907477?v=4)[wpjscc](/maintainers/wpjscc)[@wpjscc](https://github.com/wpjscc)

---

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)")[![wpjscc](https://avatars.githubusercontent.com/u/76907477?v=4)](https://github.com/wpjscc "wpjscc (4 commits)")[![makeey](https://avatars.githubusercontent.com/u/23615966?v=4)](https://github.com/makeey "makeey (1 commits)")

### Embed Badge

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

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

###  Alternatives

[league/uri-interfaces

Common tools for parsing and resolving RFC3987/RFC3986 URI

536204.9M23](/packages/league-uri-interfaces)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

184616.9k31](/packages/laudis-neo4j-php-client)[discord-php/http

Handles HTTP requests to Discord servers

25318.7k8](/packages/discord-php-http)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[christoph-kluge/reactphp-http-cors-middleware

A cors middleware for the ReactPHP HTTP-Server

1010.6k3](/packages/christoph-kluge-reactphp-http-cors-middleware)

PHPackages © 2026

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