jean-beru/fos-http-cache-cloudfront
CloudFront proxy implementation for FOSHttpCache. Create an AWS CloudFront client, instantiate the proxy with your distribution ID, purge single URLs or wildcard patterns, then call flush(). Supports custom caller reference generators to avoid duplicate requests.
TTFB).friendsofsymfony/http-cache 2.x — confirm your version before upgrading, and treat this as a hard blocker if you haven’t migrated yet.)cache:tags).friendsofsymfony/http-cache 2.x and can’t upgrade yet — v1.3.0 no longer supports it; pin to 1.2.x in the interim.*"This package lets us supercharge Laravel’s performance by offloading caching to CloudFront—AWS’s global edge network. Here’s why it’s a no-brainer:
/api routes first."**"The fos-http-cache-cloudfront package bridges FOSHttpCache and CloudFront, giving us seamless edge caching with these tradeoffs:
✅ Pros:
fos/http-cache-bundle).⚠️ Cons:
What changed in 1.3.0 (action required before bumping):
friendsofsymfony/http-cache 2.x — the 1.3.0 line requires 3.x. Audit composer.lock first; if we’re on 2.x, either plan the FOSHttpCache upgrade or stay pinned to 1.2.x.CloudFront::purge() now type-stricts the URL argument to string — calls that pass Stringable objects or loose scalars will fail. Grep for purge( call sites.CallerReference is now passed to createInvalidation as a string — fixes real-world invalidation failures caused by type coercion.Recommendation:
/products) with CloudFront invalidation.purge() calls.spatie/flysystem-cloudfront (but this is CloudFront-specific)."**"Here’s how to get started fast with this package (v1.3.0):
friendsofsymfony/http-cache 3.x):
composer require jean-beru/fos-http-cache-cloudfront async-aws/cloudfront
$cloudFront = new \Aws\CloudFront\CloudFrontClient([
'region' => env('AWS_REGION'),
'version' => 'latest',
'credentials' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
],
]);
$proxy = new \JeanBeru\HttpCacheCloudFront\Proxy\CloudFront(
client: $cloudFront,
options: [
'distribution_id' => env('CLOUDFRONT_DISTRIBUTION_ID'),
// Optional: Custom caller reference generator
'caller_reference_generator' => new \JeanBeru\HttpCacheCloudFront\CallerReference\DateCallerReferenceGenerator('YmdHi'),
]
);
string in 1.3.0):
$proxy->purge('/homepage')->purge('/assets/*')->flush();
Cache facade for seamless invalidation.Key Notes:
.env or Laravel’s AWS config.CacheBehaviors configured for the paths you’re caching.purge() or rely on FOSHttpCache 2.x. Cast call sites with (string).ProxyResponseException if AWS rejects duplicate invalidations (e.g., retry with a new caller reference)."*Example Stakeholder Alignment Table:
| Stakeholder | Key Concern | Pitch Focus |
|---|---|---|
| CEO/CFO | Cost savings, ROI | "Reduce AWS bills by 20–40% with edge caching." |
| CTO | Tech debt, scalability | "No custom code; leverages AWS’s managed infrastructure." |
| Engineering | Integration risk, maintenance | "Drop-in for FOSHttpCache 3.x; minimal AWS setup; typed API in 1.3.0." |
| DevOps | Observability, reliability | "CloudFront metrics + Laravel logging; Dependabot keeps deps current." |
| Product | User experience, performance | "Faster load times globally, especially for mobile users." |
How can I help you explore Laravel packages today?