PHPackages                             rtheunissen/guzzle-cache-handler - 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. rtheunissen/guzzle-cache-handler

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

rtheunissen/guzzle-cache-handler
================================

Guzzle 6/7 handler used to cache responses

v2.0.0(2y ago)12146.5k↓22.3%3MITPHPPHP &gt;=7.2CI failing

Since Jun 5Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/rtheunissen/guzzle-cache-handler)[ Packagist](https://packagist.org/packages/rtheunissen/guzzle-cache-handler)[ RSS](/packages/rtheunissen-guzzle-cache-handler/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (6)Versions (14)Used By (0)

Guzzle handler used to cache responses
======================================

[](#guzzle-handler-used-to-cache-responses)

[![Author](https://camo.githubusercontent.com/989b5323df87a6d4fe899296ec948ba333af9e04bbe23add7962dd26def71220/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d40727564695f746865756e697373656e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/rudi_theunissen)[![License](https://camo.githubusercontent.com/99f38a8e4e864a93bf6b82be32840a9df187cc344f1ca120b27ea8381e3f580c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f72746865756e697373656e2f67757a7a6c652d63616368652d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rtheunissen/guzzle-cache-handler)[![Latest Version](https://camo.githubusercontent.com/b61dd6fa8cf54267d2adca64febc317ac90a1237cfc59c96ebb1c8093e4b59b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72746865756e697373656e2f67757a7a6c652d63616368652d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rtheunissen/guzzle-cache-handler)[![Build Status](https://camo.githubusercontent.com/bbc27de0111b09e9e199451bab53acc22b3e7fac0c294becdb975d0bc6998df1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f72746865756e697373656e2f67757a7a6c652d63616368652d68616e646c65722e7376673f7374796c653d666c61742d737175617265266272616e63683d6d6173746572)](https://travis-ci.org/rtheunissen/guzzle-cache-handler)[![Scrutinizer](https://camo.githubusercontent.com/2e1513b301cc0d0455461adb8734d22bd8d4e447f83962898294ef4bb74c3566/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f72746865756e697373656e2f67757a7a6c652d63616368652d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/rtheunissen/guzzle-cache-handler/)[![Scrutinizer Coverage](https://camo.githubusercontent.com/c7c096f603334eca2e4fe94d7e9d9f65819b417c9f71cd197440e07daa237388/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f72746865756e697373656e2f67757a7a6c652d63616368652d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/rtheunissen/guzzle-cache-handler/)

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

[](#installation)

```
composer require rtheunissen/guzzle-cache-handler
```

Usage
-----

[](#usage)

This is a handler which caches responses for a given amount of time.

You will need an implemented [CacheInterface](https://github.com/rtheunissen/cache/blob/master/src/CacheInterface.php). See [rtheunissen/cache](https://github.com/rtheunissen/cache) for more details.

```
use Concat\Http\Handler\CacheHandler;
use Doctrine\Common\Cache\FilesystemCache;
use GuzzleHttp\Client;

// Basic directory cache example
$cacheProvider = new FilesystemCache(__DIR__ . '/cache');

// Guzzle will determine an appropriate default handler if `null` is given.
$defaultHandler = null;

// Create a cache handler with a given cache provider and default handler.
$handler = new CacheHandler($cacheProvider, $defaultHandler, [

    /**
     * @var array HTTP methods that should be cached.
     */
    'methods' => ['GET', 'HEAD', 'OPTIONS'],

    /**
     * @var integer Time in seconds to cache a response for.
     */
    'expire' => 60,

    /**
     * @var callable Accepts a request and returns true if it should be cached.
     */
    'filter' => null,
]);

// Use a PSR-3 compliant logger to log when bundles are stored or fetched.
$handler->setLogger($logger);

// Create a Guzzle 6/7 client, passing the cache handler as 'handler'.
$client = new Client([
    'handler' => $handler
]);
```

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance43

Moderate activity, may be stable

Popularity40

Moderate usage in the ecosystem

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 88.2% 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 ~247 days

Recently: every ~728 days

Total

13

Last Release

1080d ago

Major Versions

v0.5.0 → v1.0.02015-08-11

v1.1.0 → v2.0.02023-07-19

PHP version history (3 changes)v0.0.1PHP &gt;=5.4

v0.0.2PHP &gt;=5.5

v2.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/761df764fa80c32031884a5dd2376cf7e70c0fa152eaa141fd68f12b4a761b9f?d=identicon)[rtheunissen](/maintainers/rtheunissen)

---

Top Contributors

[![rtheunissen](https://avatars.githubusercontent.com/u/809191?v=4)](https://github.com/rtheunissen "rtheunissen (45 commits)")[![antoniopaisfernandes](https://avatars.githubusercontent.com/u/6171197?v=4)](https://github.com/antoniopaisfernandes "antoniopaisfernandes (6 commits)")

---

Tags

httpGuzzlepsr7cachehandler

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rtheunissen-guzzle-cache-handler/health.svg)

```
[![Health](https://phpackages.com/badges/rtheunissen-guzzle-cache-handler/health.svg)](https://phpackages.com/packages/rtheunissen-guzzle-cache-handler)
```

###  Alternatives

[kevinrob/guzzle-cache-middleware

A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)

44018.6M133](/packages/kevinrob-guzzle-cache-middleware)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k338.8M5.0k](/packages/symfony-http-client)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[eljam/guzzle-jwt-middleware

A jwt authentication middleware for guzzle 6

28761.5k3](/packages/eljam-guzzle-jwt-middleware)[rtheunissen/guzzle-log-middleware

Guzzle middleware to log requests and responses

822.3M17](/packages/rtheunissen-guzzle-log-middleware)[graham-campbell/guzzle-factory

Provides A Simple Guzzle Factory With Good Defaults

927.0M55](/packages/graham-campbell-guzzle-factory)

PHPackages © 2026

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