PHPackages                             slim/http-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. [Framework](/categories/framework)
4. /
5. slim/http-cache

ActiveLibrary[Framework](/categories/framework)

slim/http-cache
===============

Slim Framework HTTP cache middleware and service provider

1.3.0(6mo ago)1242.9M↓20.6%24[3 issues](https://github.com/slimphp/Slim-HttpCache/issues)20MITPHPPHP ^7.2 || ^8.0CI passing

Since Mar 29Pushed 5mo ago12 watchersCompare

[ Source](https://github.com/slimphp/Slim-HttpCache)[ Packagist](https://packagist.org/packages/slim/http-cache)[ Docs](https://www.slimframework.com)[ RSS](/packages/slim-http-cache/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (9)Dependencies (6)Versions (13)Used By (20)

Slim Framework HTTP Cache
=========================

[](#slim-framework-http-cache)

[![Build Status](https://github.com/slimphp/Slim-HttpCache/actions/workflows/tests.yml/badge.svg?branch=1.x)](https://github.com/slimphp/Slim-HttpCache/actions)[![Coverage Status](https://camo.githubusercontent.com/ba377bbab727cd58b65acdfb63bbe842539e656332d32d0110fd0fd3a9d05727/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f736c696d7068702f536c696d2d4874747043616368652f62616467652e7376673f6272616e63683d312e78)](https://coveralls.io/github/slimphp/Slim-HttpCache?branch=1.x)[![Latest Stable Version](https://camo.githubusercontent.com/5364eae7eb99c12ef6c84e3712452ae19e269431c47939139107f90109e04ca8/68747470733a2f2f706f7365722e707567782e6f72672f736c696d2f687474702d63616368652f76)](https://packagist.org/packages/slim/http-cache)[![License](https://camo.githubusercontent.com/4de49ccec1bbc5d1076b2134cc124944ea2103144593e69f612ef81283890fdf/68747470733a2f2f706f7365722e707567782e6f72672f736c696d2f687474702d63616368652f6c6963656e7365)](https://packagist.org/packages/slim/http-cache)

This repository contains a Slim Framework HTTP cache middleware and service provider.

Install
-------

[](#install)

Via Composer

```
$ composer require slim/http-cache
```

Requires Slim 4.0.0 or newer.

Usage
-----

[](#usage)

```
declare(strict_types=1);

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

require __DIR__.'/../vendor/autoload.php';

$app = \Slim\Factory\AppFactory::create();

// Register the http cache middleware.
$app->add(new \Slim\HttpCache\Cache('public', 86400));

// Create the cache provider.
$cacheProvider = new \Slim\HttpCache\CacheProvider();

// Register a route and let the closure callback inherit the cache provider.
$app->get(
    '/',
    function (Request $request, Response $response, array $args) use ($cacheProvider): Response {
        // Use the cache provider.
        $response = $cacheProvider->withEtag($response, 'abc');

        $response->getBody()->write('Hello world!');

        return $response;
    }
);

$app->run();
```

Testing
-------

[](#testing)

```
$ phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Josh Lockhart](https://github.com/codeguy)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

64

—

FairBetter than 99% of packages

Maintenance69

Regular maintenance activity

Popularity59

Moderate usage in the ecosystem

Community41

Growing community involvement

Maturity75

Established project with proven stability

 Bus Factor4

4 contributors hold 50%+ of commits

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 ~387 days

Recently: every ~491 days

Total

11

Last Release

194d ago

Major Versions

0.x-dev → 1.0.02020-06-18

PHP version history (4 changes)0.1.0PHP &gt;=5.4.0

0.4.0PHP &gt;=5.5.0

1.0.0PHP ^7.2

1.1.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fdc5a3a9246f368a408d3a35734fba130c48d27421f4ff222341d7790dd2ae02?d=identicon)[silentworks](/maintainers/silentworks)

![](https://www.gravatar.com/avatar/921c804872f4924b305115ce412a6f109d341b8ef3d5b905c5969275e295fc70?d=identicon)[codeguy](/maintainers/codeguy)

![](https://avatars.githubusercontent.com/u/33135?v=4)[Rob Allen](/maintainers/akrabat)[@akrabat](https://github.com/akrabat)

![](https://www.gravatar.com/avatar/0a802102aa155a7660b7402a92e3e48e918276c7a16827e0c5de9c466ab4728d?d=identicon)[l0gicgate](/maintainers/l0gicgate)

---

Top Contributors

[![adriansuter](https://avatars.githubusercontent.com/u/3974990?v=4)](https://github.com/adriansuter "adriansuter (17 commits)")[![akrabat](https://avatars.githubusercontent.com/u/33135?v=4)](https://github.com/akrabat "akrabat (14 commits)")[![l0gicgate](https://avatars.githubusercontent.com/u/6510935?v=4)](https://github.com/l0gicgate "l0gicgate (13 commits)")[![codeguy](https://avatars.githubusercontent.com/u/31677?v=4)](https://github.com/codeguy "codeguy (11 commits)")[![jerfeson](https://avatars.githubusercontent.com/u/2961357?v=4)](https://github.com/jerfeson "jerfeson (6 commits)")[![odan](https://avatars.githubusercontent.com/u/781074?v=4)](https://github.com/odan "odan (5 commits)")[![silentworks](https://avatars.githubusercontent.com/u/79497?v=4)](https://github.com/silentworks "silentworks (4 commits)")[![dhoffend](https://avatars.githubusercontent.com/u/466581?v=4)](https://github.com/dhoffend "dhoffend (4 commits)")[![JimTools](https://avatars.githubusercontent.com/u/1222052?v=4)](https://github.com/JimTools "JimTools (3 commits)")[![designermonkey](https://avatars.githubusercontent.com/u/221344?v=4)](https://github.com/designermonkey "designermonkey (3 commits)")[![zither](https://avatars.githubusercontent.com/u/1003179?v=4)](https://github.com/zither "zither (1 commits)")[![bcremer](https://avatars.githubusercontent.com/u/55820?v=4)](https://github.com/bcremer "bcremer (1 commits)")[![craveica](https://avatars.githubusercontent.com/u/6016030?v=4)](https://github.com/craveica "craveica (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![dopesong](https://avatars.githubusercontent.com/u/7201955?v=4)](https://github.com/dopesong "dopesong (1 commits)")[![flavioheleno](https://avatars.githubusercontent.com/u/471860?v=4)](https://github.com/flavioheleno "flavioheleno (1 commits)")[![geggleto](https://avatars.githubusercontent.com/u/4027602?v=4)](https://github.com/geggleto "geggleto (1 commits)")[![tflight](https://avatars.githubusercontent.com/u/4959691?v=4)](https://github.com/tflight "tflight (1 commits)")[![adoy](https://avatars.githubusercontent.com/u/80873?v=4)](https://github.com/adoy "adoy (1 commits)")

---

Tags

middlewareframeworkslimcache

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/slim-http-cache/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[slim/csrf

Slim Framework 4 CSRF protection PSR-15 middleware

3512.1M94](/packages/slim-csrf)[davidepastore/slim-validation

A slim middleware for validation based on Respect/Validation

171223.7k3](/packages/davidepastore-slim-validation)[yiisoft/yii-middleware

Yii Middleware

21151.3k1](/packages/yiisoft-yii-middleware)[bnf/slim3-psr15

PSR-15 middleware support for Slim Framework v3

10177.0k5](/packages/bnf-slim3-psr15)[igniphp/framework

Swoole, PSR-7, PSR-15 modular micro anti-framework.

2651.0k1](/packages/igniphp-framework)

PHPackages © 2026

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