Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Guzzle Cache Middleware Laravel Package

kevinrob/guzzle-cache-middleware

RFC 7234–compliant HTTP cache middleware for Guzzle 6+ using a HandlerStack. Improve API call performance with transparent caching. Supports PSR-7 and multiple storages: Laravel cache, Flysystem, PSR-6/16, and WordPress object cache.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Performance Optimization: Reduces API call latency and server load by caching HTTP responses (RFC 7234 compliant), directly addressing latency-sensitive use cases like dashboards, real-time data feeds, or high-traffic endpoints.
  • Cost Efficiency: Cuts external API costs by minimizing redundant requests (e.g., payment gateways, weather APIs, or third-party services).
  • Build vs. Buy: Avoids reinventing caching logic for Guzzle (PHP’s de facto HTTP client) while maintaining flexibility for custom storage backends (Redis, filesystem, PSR-6, etc.).
  • Roadmap Priorities:
    • Phase 1: Implement caching for public APIs (e.g., Twitter, Stripe) to reduce external costs.
    • Phase 2: Extend to internal microservices (e.g., legacy SOAP endpoints) to improve response times.
    • Phase 3: Add cache invalidation hooks for real-time updates (e.g., inventory systems).
  • Use Cases:
    • Laravel Apps: Leverage Redis/Memcached via Laravel’s built-in cache.
    • Headless CMS: Cache API responses for static site generation (e.g., Strapi, Contentful).
    • WordPress: Integrate with WP Object Cache for plugin/API responses.
    • Greedy Caching: Override API headers for internal APIs with inconsistent caching (e.g., dynamic TTLs).

When to Consider This Package

  • Adopt if:

    • Your app makes repeated identical HTTP requests (e.g., polling APIs, rendering pages with API data).
    • You need RFC 7234 compliance (proper Cache-Control, ETag, Last-Modified handling).
    • Your stack uses Guzzle 6+ and supports PHP 8.2+ (or backport to PHP 7.2+ for legacy systems).
    • You want multi-strategy caching (e.g., private for auth-sensitive data, public for static assets).
    • Your team lacks bandwidth to build a custom caching layer for Guzzle.
  • Look elsewhere if:

    • You need sub-millisecond caching (this adds ~5–50ms overhead per request; consider Varnish or Redis directly).
    • Your APIs frequently return dynamic content (e.g., real-time stock prices) where stale data is unacceptable.
    • You’re using Guzzle 5 or older (incompatible).
    • Your caching needs are simpler (e.g., only need in-memory caching; use GuzzleHttp\Cache\CacheMiddleware or symfony/cache).
    • You require distributed cache invalidation (this package handles per-request invalidation but not cross-service sync).

How to Pitch It (Stakeholders)

For Executives: "This package lets us cache API responses like a CDN for our backend—cutting costs by 30–50% for external APIs and slashing latency for internal services. For example, if our dashboard makes 100 calls to Stripe per page load, we’d reduce those to ~10 after caching. It’s a no-code solution that works with our existing Laravel/Redis stack, with minimal dev effort. ROI: Lower cloud bills + faster page loads = happier users and ops teams."

For Engineers: *"This is a battle-tested, RFC-compliant Guzzle middleware for HTTP caching with zero lock-in—supports Laravel Cache, PSR-6, Flysystem, or even WordPress. Key perks:

  • Plug-and-play: Drop into any Guzzle client in 5 lines of code.
  • Multi-strategy: Use PrivateCacheStrategy for auth-sensitive data, PublicCacheStrategy for shared assets, or GreedyCacheStrategy for APIs with broken headers.
  • Flexible storage: Works with Redis, filesystem, or even PHP arrays for testing.
  • Future-proof: Actively maintained (PHP 8.5 support, DST bug fixes), with delegating strategies for per-API customization. Tradeoff: Adds ~10ms overhead per request (negligible for API-heavy apps).* Proposal: Start with Redis-backed caching for our /api/payments and /api/weather endpoints—expect 80% reduction in external API calls."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope