amphp / http-client-cache
An async HTTP cache for Amp's HTTP client.
Fund package maintenance!
amphp
Requires
- php: >=7.2
- ext-filter: *
- ext-hash: *
- ext-json: *
- amphp/amp: ^2.4
- amphp/byte-stream: ^1.7
- amphp/cache: ^1.3
- amphp/http: ^1.5
- amphp/http-client: ^4
- kelunik/string: ^1.0
- psr/log: ^1.1
Requires (Dev)
- amphp/file: ^1.0
- amphp/log: ^1.0
- amphp/php-cs-fixer-config: dev-master
- amphp/phpunit-util: ^1.1
- monolog/monolog: ^1.24
- phpunit/phpunit: ^8 | ^7
Conflicts
- amphp/file: <0.2 || >=2
This package is auto-updated.
Last update: 2024-12-19 20:55:44 UTC
README
This package provides an HTTP cache in form of an ApplicationInterceptor
for Amp's HTTP client based on RFC 7234.
Features
- Private cache (
SingleUserCache
) - Automatic
vary
header support - Caching pushed responses
Planned Features
- Shared cache
- Conditional requests
Installation
This package can be installed as a Composer dependency.
composer require amphp/http-client-cache
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
More extensive code examples reside in the examples
directory.
Versioning
amphp/http-client-cache
follows the semver semantic versioning specification like all other amphp
packages.
Security
If you discover any security related issues, please email me@kelunik.com
instead of using the issue tracker.
License
The MIT License (MIT). Please see LICENSE
for more information.