PHPackages                             ryudith/mezzio-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. ryudith/mezzio-response-cache

ActiveLibrary[Caching](/categories/caching)

ryudith/mezzio-response-cache
=============================

Cache response based URL route key for Mezzio.

00PHP

Since Jul 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ryudith/mezzio-response-cache)[ Packagist](https://packagist.org/packages/ryudith/mezzio-response-cache)[ RSS](/packages/ryudith-mezzio-response-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

**mezzio-response-cache**
=========================

[](#mezzio-response-cache)

**`Ryudith\MezzioResponseCache`** is middleware for Mezzio framework to save response produce by request (default use request path as cache key).

**Installation**
----------------

[](#installation)

To install run command :

```
$ composer require ryudith/mezzio-response-cache
```

**Usage**
---------

[](#usage)

#### Add **`Ryudith\MezzioResponseCache\ConfigProvider`** to **`config/config.php`**

[](#add-ryudithmezzioresponsecacheconfigprovider-to-configconfigphp)

```
...

$aggregator = new ConfigAggregator([
    ...
    \Laminas\Diactoros\ConfigProvider::class,

    Ryudith\MezzioResponseCache\ConfigProvider::class,  // pipe(ErrorHandler::class);
    $app->pipe(ResponseCacheMiddleware::class);  //  You can put `ResponseCacheMiddleware::class` before or after `ErrorHandler::class` or anywhere you want depend on you need. Basically, middleware do check cache path key (default behavior) if not exists then generate response else it will give cache. It also support custom configurations for exclude path or IP from cache for example (See *`custom configurations`* below).

**Custom Configurations**
-------------------------

[](#custom-configurations)

1. **`default_ttl`**
    Default time to life cache in second, default 3600 (or 1 hour).

    > ```
    > ...
    > 'mezzio_response_cache' => [
    >    'default_ttl' => 3600,
    > ],
    > ...
    > ```
2. **`exclude_ip_from_cache`**
    IP list to exclude cache (list array), default empty array.

    > ```
    > ...
    > 'mezzio_response_cache' => [
    >    'exclude_ip_from_cache' => [
    >        '192.168.0.1',
    >        '127.0.0.1',
    >    ],
    > ],
    > ...
    > ```
3. **`exlcude_path_from_cache`**
    Route path list to exclude cache (list array), default empty array.

    > ```
    > ...
    > 'mezzio_response_cache' => [
    >    'exlcude_path_from_cache' => [
    >        '/about',
    >        '/api/post',
    >    ],
    > ],
    > ...
    > ```
4. **`cache_handler_class`**
    Class to handle cache mechanism. Custom class to handle cache middleware.

    > ```
    > ...
    > 'mezzio_response_cache' => [
    >    'cache_handler_class' => CacheHandler\CacheHandler::class,
    > ],
    > ...
    > ```
5. **`cache_storage_handler_class`**
    Class to handle cache storage mechanism. Custom class to handle cache storage for cache handler in middleware, default is file system storage.

    > ```
    > 'mezzio_response_cache' => [
    >    'cache_storage_handler_class' => Storage\FileSystemCacheHandler::class,
    > ],
    > ```
6. **`cache_metadata_location`**
    Path location for metadata cache. Path directory location where `cache_storage_handler_class` will save cache metadata for default cache storage.

    > ```
    > 'mezzio_response_cache' => [
    >    'cache_metadata_location' => './data/cache/response/content',
    > ],
    > ```
7. **`cache_content_location`**
    Path location for actual cache content. Path directory location where `cache_storage_handler_class` will save cache content data for default cache storage.

    > ```
    > 'mezzio_response_cache' => [
    >    'cache_content_location' => './data/cache/response/content',
    > ],
    > ```

Simple Helper
-------------

[](#simple-helper)

#### **Web**

[](#web)

Add `Ryudith\MezzioResponseCache\Helper\WebHandlerCache` to `factories` configuration, usually inside file `config/dependencies.global.php`.

```
...
'factories' => [
    ...

    // add this to enable web simple helper
    Ryudith\MezzioResponseCache\Helper\WebHandlerCache::class => Ryudith\MezzioResponseCache\Helper\WebHandlerCacheFactory::class
    ...
]
...
```

Then register helper to route in file `config/route.php`.

```
...
$app->get('/cacheresponse/helper', Ryudith\MezzioResponseCache\Helper\WebHandlerCache::class);
...
```

> change route path `/cacheresponse/helper` to your own route path.

Next you can access simple web helper from `http://localhost:8080/cacheresponse/helper?o=clear` or `http://localhost:8080/cacheresponse/helper?o=delete&p=/about` from browser.

> change address depend your Mezzio app configuration (address above is just example).

**Query parameter used by simple web helper is :**

1. **`o`**
    The operation, `clear` or `delete`.
2. **`k`**
    Sha1 cache key, default generate with `sha1($uriPath)`.
3. **`p`**
    Cache path, if you don't know what sha1 cache key, you can use path cache instead. If you use `k` and `p` at same time, helper will pick `k` value instead and ignore `p` query parameter.

Documentation
-------------

[](#documentation)

[API Documentation](https://ryudith.github.io/mezzio-response-cache/api/index.html)

[Issues or Questions](https://github.com/ryudith/mezzio-response-cache/issues)

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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://www.gravatar.com/avatar/9bff5de81a5825d605a804957df6490585f58156f3900614bf13df2b9385e1a7?d=identicon)[ryudith](/maintainers/ryudith)

---

Top Contributors

[![ryudith](https://avatars.githubusercontent.com/u/2020830?v=4)](https://github.com/ryudith "ryudith (22 commits)")

### Embed Badge

![Health badge](/badges/ryudith-mezzio-response-cache/health.svg)

```
[![Health](https://phpackages.com/badges/ryudith-mezzio-response-cache/health.svg)](https://phpackages.com/packages/ryudith-mezzio-response-cache)
```

###  Alternatives

[predis/predis

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

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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