PHPackages                             amphp/http-client-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. amphp/http-client-cache

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

amphp/http-client-cache
=======================

An async HTTP cache for Amp's HTTP client.

v1.0.0(6y ago)101582[1 issues](https://github.com/amphp/http-client-cache/issues)1MITPHPPHP &gt;=7.2CI failing

Since Aug 14Pushed 2y ago5 watchersCompare

[ Source](https://github.com/amphp/http-client-cache)[ Packagist](https://packagist.org/packages/amphp/http-client-cache)[ RSS](/packages/amphp-http-client-cache/feed)WikiDiscussions 2.x Synced 2d ago

READMEChangelog (2)Dependencies (13)Versions (4)Used By (1)

http-client-cache
=================

[](#http-client-cache)

[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)

This package provides an HTTP cache in form of an `ApplicationInterceptor` for [Amp's HTTP client](https://github.com/amphp/http-client) based on [RFC 7234](https://tools.ietf.org/html/rfc7234.html).

Features
--------

[](#features)

- Private cache (`SingleUserCache`)
- Automatic `vary` header support
- Caching pushed responses

Planned Features
----------------

[](#planned-features)

- Shared cache
- Conditional requests

Installation
------------

[](#installation)

This package can be installed as a [Composer](https://getcomposer.org/) dependency.

```
composer require amphp/http-client-cache
```

Usage
-----

[](#usage)

Currently, only a `SingleUserCache` is provided. Therefore, it is unsafe to use a single instance for multiple users, e.g. different access tokens.

```
use Amp\Cache\FileCache;
use Amp\Http\Client\HttpClientBuilder;
use Amp\Http\Client\Cache\SingleUserCache;
use Amp\Sync\LocalKeyedMutex;

$cache = new FileCache(__DIR__, new LocalKeyedMutex);

$client = (new HttpClientBuilder)
    ->intercept(new SingleUserCache($cache, $logger))
    ->build();
```

Examples
--------

[](#examples)

More extensive code examples reside in the [`examples`](./examples) directory.

Versioning
----------

[](#versioning)

`amphp/http-client-cache` follows the [semver](http://semver.org/) semantic versioning specification like all other `amphp` packages.

Security
--------

[](#security)

If you discover any security related issues, please email [`me@kelunik.com`](mailto:me@kelunik.com) instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.6% 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 ~559 days

Total

4

Last Release

833d ago

Major Versions

1.x-dev → 2.x-dev2024-03-19

PHP version history (3 changes)v1.0.0-rc1PHP &gt;=7.1

v1.0.0PHP &gt;=7.2

2.x-devPHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1628287?v=4)[Aaron Piotrowski](/maintainers/Trowski)[@trowski](https://github.com/trowski)

![](https://www.gravatar.com/avatar/12852217f3369e8144bc9ce6ac2a2341c28c5512c5b3df5749bfbbd45b6877ff?d=identicon)[kelunik](/maintainers/kelunik)

---

Top Contributors

[![kelunik](https://avatars.githubusercontent.com/u/2743004?v=4)](https://github.com/kelunik "kelunik (55 commits)")[![trowski](https://avatars.githubusercontent.com/u/1628287?v=4)](https://github.com/trowski "trowski (9 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (1 commits)")

---

Tags

amphpasynchttp-cachehttp-clientphprfc-7234

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k885.1k22](/packages/danog-madelineproto)[amphp/http-server

A non-blocking HTTP application server for PHP based on Amp.

1.3k5.9M104](/packages/amphp-http-server)[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k853.6M8.3k](/packages/symfony-http-kernel)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k338.8M4.6k](/packages/symfony-http-client)[amphp/http-client

An advanced async HTTP client library for PHP, enabling efficient, non-blocking, and concurrent requests and responses.

7298.5M190](/packages/amphp-http-client)[api-platform/metadata

API Resource-oriented metadata attributes and factories

244.5M182](/packages/api-platform-metadata)

PHPackages © 2026

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