PHPackages                             clickalicious/cachingmiddleware - 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. clickalicious/cachingmiddleware

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

clickalicious/cachingmiddleware
===============================

The PSR-7 middleware for caching compatible to PSR-6.

v1.1.1(10y ago)31.1k11BSD-3-ClausePHPPHP &gt;=5.5.0

Since Oct 25Pushed 9y ago2 watchersCompare

[ Source](https://github.com/clickalicious/caching-middleware)[ Packagist](https://packagist.org/packages/clickalicious/cachingmiddleware)[ Docs](https://github.com/clickalicious/CachingMiddleware)[ RSS](/packages/clickalicious-cachingmiddleware/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (8)Versions (7)Used By (1)

[![](https://avatars0.githubusercontent.com/u/26927954?v=3&s=80)](https://avatars0.githubusercontent.com/u/26927954?v=3&s=80)

---

[![Logo of Caching-Middleware](docs/logo-large.png)](docs/logo-large.png)

The `PSR-7` **middleware for caching** compatible to `PSR-6`.

[![Build Status](https://camo.githubusercontent.com/212198608967fadf30e6f233df3e6674bede9dd60eb0f9147b8b37d2a6bb1a5f/68747470733a2f2f7472617669732d63692e6f72672f636c69636b616c6963696f75732f63616368696e672d6d6964646c65776172652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/clickalicious/caching-middleware)[![Codacy grade](https://camo.githubusercontent.com/b675009aa0a405ef2ba0efb8abdcb18fec29a6001601e580bdec6beaeab1c140/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f67726164652f61346634383439383562643734633832623938646564376531623066343361662e737667)](https://www.codacy.com/app/benjamin-carl/caching-middleware?utm_source=github.com&utm_medium=referral&utm_content=clickalicious/caching-middleware&utm_campaign=Badge_Grade)[![Codacy coverage](https://camo.githubusercontent.com/7ce9338354e47f0a613f5d1c3533e53b38eb547b7c728966c5f85bbe2092b595/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f636f7665726167652f61346634383439383562643734633832623938646564376531623066343361662e737667)](https://www.codacy.com/app/benjamin-carl/caching-middleware?utm_source=github.com&utm_medium=referral&utm_content=clickalicious/caching-middleware&utm_campaign=Badge_Grade)[![clickalicious open source](https://camo.githubusercontent.com/c244587ebb73cb5386d137729f3bb3348c448eef1782b945b6d03f4f5b5361c2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636c69636b616c6963696f75732d6f70656e2d2d736f757263652d677265656e2e7376673f7374796c653d666c6174)](https://clickalicious.de/)[![GitHub release](https://camo.githubusercontent.com/d4d4f5b606bd374cb8040eeb26c748ad8a2a2c810f63f554eb2390bab8b10a95/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f636c69636b616c6963696f75732f63616368696e672d6d6964646c65776172652e7376673f7374796c653d666c6174)](https://github.com/clickalicious/caching-middleware/releases)[![license](https://camo.githubusercontent.com/850eae1099d2b05f53383473d7cd51f9bc1ab09b7d0d9e5122f1dd930efdcc6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e737667)](https://opensource.org/licenses/MIT)[![Issue Stats](https://camo.githubusercontent.com/b957d8b07439bef33606da831689840261286ac2249b7b21e57c6e7e9534b62a/68747470733a2f2f696d672e736869656c64732e696f2f697373756573746174732f692f6769746875622f636c69636b616c6963696f75732f63616368696e672d6d6964646c65776172652e737667)](https://github.com/clickalicious/caching-middleware/issues)[![Dependency Status](https://camo.githubusercontent.com/ec3e3c92d3f34930f70d177b47c2b213d231d6f4051a8367ea5723c1b885d5e9/68747470733a2f2f646570656e64656e637963692e636f6d2f6769746875622f636c69636b616c6963696f75732f63616368696e672d6d6964646c65776172652f6261646765)](https://dependencyci.com/github/clickalicious/caching-middleware)Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Example](#example)
- [Requirements](#requirements)
- [Philosophy](#philosophy)
- [Versioning](#versioning)
- [Roadmap](#roadmap)
- [Security-Issues](#security-issues)
- [License »](LICENSE)

Features
--------

[](#features)

- Caching of almost any content produced in a PHP execution loop like `PHP`, `HTML` (...)
- Stackable into `PSR-7` stacks for easy integration
- Compatible to all `PSR-6` caching implementations and a lot of caching backends
- High performance (developed using a profiler)
- Lightweight and high-quality codebase (following `PSR-1,2,4,7`)
- 100% `PSR-7` middleware compatibility
- 100% `PSR-6` caching compatibility
- Clean &amp; well documented code
- Unit-tested with a good coverage

Example
-------

[](#example)

This is just a simple demonstration on how to get started using this middleware library in a very simple context. Put a `Cache` in queue and use a `PSR-6 Cache` (`Filesystem` as backend - but you could also use `Redis`, `Memcached`, `MySQL` or any other backend implemented a `PSR-6` caching layer ...):

```
/**
 * Fill queue for running "Caching Middleware"
 *
 * @param \Psr\Http\Message\ServerRequestInterface $request  Request (PSR) to process
 * @param \Psr\Http\Message\ResponseInterface      $response Response (PSR) to use
 * @param callable                                 $next     Next middleware in stack
 *
 * @return \Psr\Http\Message\ResponseInterface A PSR compatible response
 */
$queue[] = function (Request $request, Response $response, callable $next) {

    // Create cache item factory
    $cacheItemFactory = function ($key) {
        return new CacheItem($key);
    };

    // Create cache item key factory
    $cacheItemKeyFactory = function (Request $request) {
        static $key = null;
        if (null === $key) {
            $uri     = $request->getUri();
            $slugify = new Slugify();
            $key     = $slugify->slugify(trim($uri->getPath(), '/').($uri->getQuery() ? '?'.$uri->getQuery() : ''));
        }

        return $key;
    };

    // Get cache
    $cachingMiddleWare = new Clickalicious\Caching\Middleware\Cache(
        new CacheItemPool('Filesystem'),
        $cacheItemFactory,
        $cacheItemKeyFactory
    );

    return $cachingMiddleWare($request, $response, $next);
};
```

Requirements
------------

[](#requirements)

- `PHP >= 5.6` (compatible up to version `7.2` as well as `HHVM`)

Philosophy
----------

[](#philosophy)

`Caching Middleware` is a `PSR-7` compatible middleware based on `PSR-6` compatible cache implementations. `Caching Middleware` isn't a unicorn - it's good but it maybe going to change with time. Try it, run it ... ♥ it ;)

Versioning
----------

[](#versioning)

For a consistent versioning we decided to make use of `Semantic Versioning 2.0.0` . Its easy to understand, very common and known from many other software projects.

Roadmap
-------

[](#roadmap)

- Cache whole response instead just rendered HTML (Headers as well for example)
- Implement [flysystem](http://flysystem.thephpleague.com/ "flysystem") as Driver for `PSR-Cache`

[![Throughput Graph](https://camo.githubusercontent.com/57356211685a077ef69d62f708eacc1c4ef7e49cfe43ea8f331271e66f719d8c/68747470733a2f2f6772617068732e776166666c652e696f2f636c69636b616c6963696f75732f63616368696e672d6d6964646c65776172652f7468726f7567687075742e737667)](https://waffle.io/clickalicious/caching-middleware/metrics)

Security Issues
---------------

[](#security-issues)

If you encounter a (potential) security issue don't hesitate to get in contact with us `opensource@clickalicious.de` before releasing it to the public. So i get a chance to prepare and release an update before the issue is getting shared. Thank you!

Participate &amp; Share
-----------------------

[](#participate--share)

... yeah. If you're a code monkey too - maybe we can build a force ;) If you would like to participate in either **Code**, **Comments**, **Documentation**, **Wiki**, **Bug-Reports**, **Unit-Tests**, **Bug-Fixes**, **Feedback** and/or **Critic** then please let us know as well! [![](https://camo.githubusercontent.com/2ae8719c2efbe82ef2938210c2dc507fffdfa7a73a1d982a01e5b27f7269af52/687474703a2f2f6a70696c6c6f72612e636f6d2f6769746875622d747769747465722d627574746f6e2f696d672f74776565742e706e67)](https://twitter.com/intent/tweet?hashtags=&original_referer=http%3A%2F%2Fgithub.com%2F&text=Caching-Middleware%20-%20PSR-7%20compatible%20stack%20implementation%20based%20on%20PSR-6.%20%40phpfluesterer%20%23caching-middleware%20%23php%20https%3A%2F%2Fgithub.com%2Fclickalicious%2Fcaching-middleware&tw_p=tweetbutton)

Sponsors
--------

[](#sponsors)

Thanks to our sponsors and supporters:

JetBrainsNavicat[![](https://camo.githubusercontent.com/b0914f08f6b588c7178490d5faf4b159b5c9dd3378288c92812c76aff1936790/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f6173736574732f6d656469612f6f70656e2d67726170682f6a6574627261696e735f323530783235302e706e67)](https://www.jetbrains.com/phpstorm/ "PHP IDE :: JetBrains PhpStorm")[![](https://camo.githubusercontent.com/05c63082503800035599f1c0cfc7bf20806173061e03634107592d18d096e648/687474703a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f656e2f392f39302f5072656d69756d536f66745f4e6176696361745f5072656d69756d5f4c6f676f2e706e67)](http://www.navicat.com/ "Navicat GUI - DB GUI-Admin-Tool for MySQL, MariaDB, SQL Server, SQLite, Oracle & PostgreSQL")###### Copyright

[](#copyright)

Icons made by [Prosymbols](http://www.flaticon.com/authors/prosymbols "Prosymbols") from [www.flaticon.com](http://www.flaticon.com "Flaticon") is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/ "Creative Commons BY 3.0")

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

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

###  Release Activity

Cadence

Every ~57 days

Total

4

Last Release

3685d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/41051d0345550be4293d3cdb46cf4eadce771501ed813d3f736e648027f76c0e?d=identicon)[clickalicious](/maintainers/clickalicious)

---

Top Contributors

[![benjamin-carl](https://avatars.githubusercontent.com/u/514566?v=4)](https://github.com/benjamin-carl "benjamin-carl (8 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

cachingmiddlewarepsr-6psr-7stackpsr-7middlewarecachecachingstackpsr-6Relay

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/clickalicious-cachingmiddleware/health.svg)

```
[![Health](https://phpackages.com/badges/clickalicious-cachingmiddleware/health.svg)](https://phpackages.com/packages/clickalicious-cachingmiddleware)
```

###  Alternatives

[psr/http-server-middleware

Common interface for HTTP server-side middleware

18091.2M1.5k](/packages/psr-http-server-middleware)[mezzio/mezzio

PSR-15 Middleware Microframework

3883.6M97](/packages/mezzio-mezzio)[relay/relay

A PSR-15 server request handler.

3302.1M86](/packages/relay-relay)[laminas/laminas-stratigility

PSR-7 middleware foundation for building and dispatching middleware pipelines

586.6M81](/packages/laminas-laminas-stratigility)[middlewares/utils

Common utils for PSR-15 middleware packages

503.4M92](/packages/middlewares-utils)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.0M61](/packages/mezzio-mezzio-router)

PHPackages © 2026

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