PHPackages                             jean-beru/fos-http-cache-cloudfront - 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. jean-beru/fos-http-cache-cloudfront

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

jean-beru/fos-http-cache-cloudfront
===================================

Tools to manage CloudFront HTTP caching proxy with PHP

1.2.0(1y ago)02.4k↓50%11MITPHPPHP ^8.1

Since Apr 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Jean-Beru/fos-http-cache-cloudfront)[ Packagist](https://packagist.org/packages/jean-beru/fos-http-cache-cloudfront)[ RSS](/packages/jean-beru-fos-http-cache-cloudfront/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (5)Used By (1)

CloudFront implementation of FOSHttpCache
=========================================

[](#cloudfront-implementation-of-foshttpcache)

[![Latest Version](https://camo.githubusercontent.com/fb7135420b75b6ac255391104d9b6b92fe5ccc52088b2ed556fe1a17c35bc12e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4a65616e2d426572752f666f732d687474702d63616368652d636c6f756466726f6e742e7376673f7374796c653d666c61742d737175617265)](https://github.com/Jean-Beru/fos-http-cache-cloudfront/releases)[![Total Downloads](https://camo.githubusercontent.com/ccaef5679e05a9226f14238d656c602f8299b673cfe78ddad2cbb455761b612e/68747470733a2f2f706f7365722e707567782e6f72672f4a65616e2d426572752f666f732d687474702d63616368652d636c6f756466726f6e742f646f776e6c6f616473)](https://packagist.org/packages/Jean-Beru/fos-http-cache-cloudfront)[![Monthly Downloads](https://camo.githubusercontent.com/328f71497e7d370a01efa797ef0707f2ad0c8ab312723d1af02979b83f5c73b7/68747470733a2f2f706f7365722e707567782e6f72672f4a65616e2d426572752f666f732d687474702d63616368652d636c6f756466726f6e742f642f6d6f6e74686c792e706e67)](https://packagist.org/packages/Jean-Beru/fos-http-cache-cloudfront)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENCE)[![Tests](https://github.com/Jean-Beru/fos-http-cache-cloudfront/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Jean-Beru/fos-http-cache-cloudfront/actions/workflows/ci.yml?query=branch%3Amain)

This library provides an implementation of [FOSHttpCache](https://github.com/FriendsOfSymfony/FOSHttpCache/) for [CloudFront](https://aws.amazon.com/cloudfront/).

Usage
-----

[](#usage)

### Initialize dependency

[](#initialize-dependency)

First, create an instance of `AsyncAws\CloudFront\CloudFrontClient` to allow the proxy to make requests. See [aws-sdk-php documentation](https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.AwsClient.html#___construct)for more information.

```
use Aws\CloudFront\CloudFrontClient;

$client = new CloudFrontClient(/* client configuration */);
```

### Create the CloudFront proxy

[](#create-the-cloudfront-proxy)

To instantiate the proxy, pass the CloudFront client and the AWS CloudFront distribution ID.

```
use JeanBeru\HttpCacheCloudFront\Proxy\CloudFront;

$proxy = new CloudFront(
    client: $client,
    options: [
      'distribution_id' => 'XYZ1234657',
    ],
);
```

### Invalidate URLs

[](#invalidate-urls)

To invalidate `/homepage` URL and all URLs matching the `/assets/*` pattern on the "XYZ1234657" distribution.

```
$proxy
    ->purge('/homepage')
    ->purge('/assets/*')
    // To send the purge request, flush() method must be called
    ->flush()
;
```

### Avoid request duplication

[](#avoid-request-duplication)

CloudFront APIs asks for a "caller reference" to avoid duplicated requests. By default, this library use the [UniqIdCallerReferenceGenerator](./CallerReference/UniqIdCallerReferenceGenerator.php) to generate a unique identifier.

You can use other generators present in the [CallerReference folder](./CallerReference/) or implement your own by implementing the [CallerReferenceGenerator](./CallerReference/CallerReferenceGenerator) interface.

For instance, if you want to avoid duplicate calls in the same minute:

```
use JeanBeru\HttpCacheCloudFront\Proxy\CloudFront;
use JeanBeru\HttpCacheCloudFront\CallerReference\DateCallerReferenceGenerator;

$proxy = new CloudFront(
    client: $client,
    options: [
      'distribution_id' => 'XYZ1234657',
      'caller_reference_generator' => new DateCallerReferenceGenerator('YmdHi'),
    ],
);
```

If a duplication is detected by AWS, a `FOS\HttpCache\Exception\ProxyResponseException` will be thrown.

Resources
---------

[](#resources)

- [Report issues](https://github.com/jean-beru/fos-http-cache-cloudfront/issues) and [send Pull Requests](https://github.com/jean-beru/fos-http-cache-cloudfront/pulls)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% 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 ~141 days

Total

4

Last Release

714d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ac44d8716de449976a457b72b4cdca816bcd13c8f13fdc7092075704ff475622?d=identicon)[Jean-Beru](/maintainers/Jean-Beru)

---

Top Contributors

[![Jean-Beru](https://avatars.githubusercontent.com/u/6114779?v=4)](https://github.com/Jean-Beru "Jean-Beru (17 commits)")[![dbu](https://avatars.githubusercontent.com/u/76576?v=4)](https://github.com/dbu "dbu (2 commits)")

---

Tags

httpcachingpurgecloudfrontinvalidation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jean-beru-fos-http-cache-cloudfront/health.svg)

```
[![Health](https://phpackages.com/badges/jean-beru-fos-http-cache-cloudfront/health.svg)](https://phpackages.com/packages/jean-beru-fos-http-cache-cloudfront)
```

###  Alternatives

[friendsofsymfony/http-cache-bundle

Set path based HTTP cache headers and send invalidation requests to your HTTP cache

43813.2M47](/packages/friendsofsymfony-http-cache-bundle)[friendsofsymfony/http-cache

Tools to manage HTTP caching proxies with PHP

36114.7M36](/packages/friendsofsymfony-http-cache)[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.0B3.2k](/packages/guzzlehttp-psr7)[psr/http-message

Common interface for HTTP messages

7.1k1.0B5.5k](/packages/psr-http-message)[psr/http-factory

PSR-17: Common interfaces for PSR-7 HTTP message factories

1.9k692.9M1.9k](/packages/psr-http-factory)[psr/http-client

Common interface for HTTP clients

1.7k680.7M2.1k](/packages/psr-http-client)

PHPackages © 2026

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