graham-campbell/cache-plugin
A Laravel package from Graham Campbell that adds a plugin layer to cache stores, letting you attach custom behavior to cache reads, writes, and deletes without changing the underlying driver. Useful for logging, metrics, and other cross-cutting concerns.
Cache::remember(), or adopting a thin plugin that already implements caching semantics. The decision is which of the three we standardize on, not whether we cache. Note that the supplied documentation describes two materially different products — a lightweight Laravel-compatible cache layer with pluggable stores and namespaced keys, versus an HTTPlug/PSR-18 HTTP cache plugin with freshness/revalidation/Vary handling. The first half-day of any work must confirm which one we are buying before the build-vs-buy answer is meaningful.spatie/laravel-responsecache, Laravel cache), and edge/CDN caching (Cloudflare/Fastly). Being explicit prevents a stakeholder expecting page-speed wins from an API-cost change.Consider it when:
Look elsewhere when:
spatie/laravel-responsecache, or an edge layer.Http facade without integration work. The HTTP-flavored integration decorates a PSR-18 client via PluginClient, and Laravel's cache repository is not PSR-6 — both require deliberate wiring (a pool adapter, a custom client binding, or an internal service wrapper). None of it is hard; none of it is composer require and forget.For executives (one paragraph): A meaningful share of our outbound traffic to paid and rate-limited third-party APIs is redundant — the same data requested repeatedly within minutes. This package is a small caching layer for our HTTP client that stores those responses and reuses them, honoring the provider's own cache instructions. The business case is concrete: lower vendor API spend, faster page and job execution, and fewer user-visible failures during a vendor outage because we can serve recently cached data instead of an error. It is infrastructure, not a customer-facing feature — cheap to adopt, easy to remove, and measured in reduced invoices and avoided incidents rather than new functionality. Three caveats to state plainly: adoption and community maturity are low, so we adopt behind our own abstraction with a documented exit; the documentation is ambiguous about exactly which product this is, so the first deliverable is a half-day verification rather than a build; and the highest-severity risk is cache-key safety across tenants, mitigated with a written caching policy and review before promotion beyond pilot.
For engineering (the short version): Treat this as a time-boxed experiment, not a platform commitment. Step one is a half-day resolution spike to confirm from composer.json and src/ whether this is the HTTPlug/PSR-18 cache plugin or a Laravel-flavored cache layer — the supplied materials describe both, and the integration story, estimate and risk profile differ materially. Assuming the HTTP-cache variant: it is HTTP-compliant response caching plugged into any PSR-6 pool we already run, not a Laravel cache driver. Inside Laravel the friction is structural — the Http facade is Guzzle-native while this decorates a PSR-18 client, and Laravel's cache is not PSR-6 — so we need a pool adapter plus one small typed service rather than a drop-in. Recommended path: build one bounded client class behind our own interface, pilot on a single high-volume read-only integration with generous TTLs and a kill switch, and measure hit rate, latency and vendor spend before and after. Add our own metrics and tracing — observability is not included — and write the caching policy (keys, TTLs, tenant scoping, no-store/private behavior, max body size) before scaling, since mis-keyed responses are the real blast radius. Also budget a small test-harness line item: swapping the client can silently bypass Http::fake() in existing tests. If the spike shows an internal wrapper is comparable in effort, default to "borrow the pattern, own the code" and drop the dependency — reversibility is the strongest argument for running the pilot at all.
How can I help you explore Laravel packages today?