jean-beru/fos-http-cache-cloudfront
CloudFront proxy implementation for FOSHttpCache. Create a CloudFrontClient, configure your distribution ID, then purge/invalidate specific URLs or patterns (e.g., /assets/*) and flush requests. Supports caller reference generators to avoid duplicate invalidations.
TTFB).HttpCache and want to extend it to CloudFront.cache:tags).*"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:
Recommendation:
/products) with CloudFront invalidation.spatie/flysystem-cloudfront (but this is CloudFront-specific)."**"Here’s how to get started fast with this package:
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'),
]
);
$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.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; minimal AWS setup." |
| DevOps | Observability, reliability | "CloudFront metrics + Laravel logging for visibility." |
| Product | User experience, performance | "Faster load times globally, especially for mobile users." |
How can I help you explore Laravel packages today?