This package provides an HTTP cache in form of an ApplicationInterceptor
for Amp's HTTP client based on RFC 7234.
- Private cache (
SingleUserCache
) - Automatic
vary
header support - Caching pushed responses
- Shared cache
- Conditional requests
This package can be installed as a Composer dependency.
composer require amphp/http-client-cache
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();
More extensive code examples reside in the examples
directory.
amphp/http-client-cache
follows the semver semantic versioning specification like all other amphp
packages.
If you discover any security related issues, please email me@kelunik.com
instead of using the issue tracker.
The MIT License (MIT). Please see LICENSE
for more information.