Download the PHP package kevinrob/guzzle-cache-middleware without Composer
On this page you can find all versions of the php package kevinrob/guzzle-cache-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kevinrob/guzzle-cache-middleware
More information about kevinrob/guzzle-cache-middleware
Files in kevinrob/guzzle-cache-middleware
Package guzzle-cache-middleware
Short Description A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)
License MIT
Homepage https://github.com/Kevinrob/guzzle-cache-middleware
Informations about the package guzzle-cache-middleware
guzzle-cache-middleware
A HTTP Cache for Guzzle 6+. It's a simple Middleware to be added in the HandlerStack.
Goals
- RFC 7234 compliance
- Performance and transparency
- Assured compatibility with PSR-7
Built-in storage interfaces
Installation
composer require kevinrob/guzzle-cache-middleware
or add it the your composer.json
and run composer update kevinrob/guzzle-cache-middleware
.
Why?
Performance. It's very common to do some HTTP calls to an API for rendering a page and it takes times to do it.
How?
With a simple Middleware added at the top of the HandlerStack
of Guzzle.
Examples
Doctrine/Cache
You can use a cache from Doctrine/Cache
:
You can use ChainCache
for using multiple CacheProvider
instances. With that provider, you have to sort the different caches from the faster to the slower. Like that, you can have a very fast cache.
Laravel cache
You can use a cache with Laravel, e.g. Redis, Memcache etc.:
Flysystem
WordPress Object Cache
Public and shared
It's possible to add a public shared cache to the stack:
Greedy caching
In some cases servers might send insufficient or no caching headers at all. Using the greedy caching strategy allows defining an expiry TTL on your own while disregarding any possibly present caching headers:
Delegate caching
Because your client may call different apps, on different domains, you may need to define which strategy is suitable to your requests.
To solve this, all you have to do is to define a default cache strategy, and override it by implementing your own Request Matchers.
Here's an example:
With this example:
- All requests to
example.org
will be handled byPublicCacheStrategy
- All requests to
twitter.com
will be handled byPrivateCacheStrategy
- All other requests won't be cached.
Drupal
See Guzzle Cache module.
Links that talk about the project
Buy me a coffee
If you like this project, you can buy me a coffee! (or a beer 😉)
Development
Docker quick start
Initialization
Running test
Entering container shell
All versions of guzzle-cache-middleware with dependencies
guzzlehttp/guzzle Version ^6.0 || ^7.0
guzzlehttp/promises Version ^1.4 || ^2.0
guzzlehttp/psr7 Version ^1.7.0 || ^2.0.0