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

Laravel Responsecache Laravel Package

spatie/laravel-responsecache

Cache full Laravel responses to speed up your app. Automatically caches successful text-based GET requests (HTML/JSON), with easy middleware per route, configurable lifetimes, and optional stale-while-revalidate “grace” caching to refresh in the background.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Performance Optimization: Accelerate API and web response times by caching entire HTTP responses (HTML, JSON, etc.), reducing backend load and improving latency for high-traffic endpoints (e.g., dashboards, static content, or read-heavy APIs).
  • Cost Efficiency: Reduce cloud infrastructure costs (e.g., AWS Lambda, serverless, or shared hosting) by minimizing repeated execution of expensive queries or computations.
  • Build vs. Buy: Avoid reinventing caching logic (e.g., manual Redis/DB caching) when this package provides a maintained, battle-tested solution with flexible configurations (e.g., flexible caching, tags, and granular control).
  • Roadmap Priorities:
    • Phase 1: Implement for public-facing read-heavy routes (e.g., blogs, product listings).
    • Phase 2: Extend to internal tools (e.g., admin dashboards) where stale data is acceptable.
    • Phase 3: Integrate with CDN invalidation or edge caching (e.g., Cloudflare) for hybrid caching strategies.
  • Use Cases:
    • Content-Heavy Apps: E-commerce product pages, documentation sites, or news platforms.
    • APIs with Static Responses: Public APIs with infrequently changing data (e.g., currency rates, configuration endpoints).
    • Legacy System Modernization: Speed up monolithic Laravel apps without major refactoring.
    • A/B Testing: Cache variant responses to reduce backend load during experiments.

When to Consider This Package

Adopt when:

  • Your Laravel app serves repeated identical responses (e.g., GET requests with no dynamic data).
  • You need sub-second improvements for high-traffic routes without complex caching logic.
  • Stale data is tolerable (e.g., dashboards, non-critical content) or you’re using flexible caching for seamless updates.
  • Your team lacks expertise in low-level caching (e.g., Redis key design, cache invalidation).
  • You’re using Laravel 11+ and PHP 8.4+ (current supported versions).

Look elsewhere if:

  • Your app relies on real-time data (e.g., stock tickers, live chats) where caching introduces unacceptable latency.
  • Responses are highly dynamic (e.g., personalized user feeds, frequent DB changes).
  • You need fine-grained object-level caching (e.g., caching specific Eloquent models) → Use Laravel’s built-in cache or packages like spatie/laravel-cache.
  • Your infrastructure already uses edge caching (e.g., Cloudflare, Varnish) that conflicts with this middleware.
  • You require cache invalidation triggers beyond tags (e.g., event-based invalidation) → Consider custom logic or spatie/laravel-cache.

How to Pitch It (Stakeholders)

For Executives: "This package lets us instantly speed up our slowest endpoints by caching full HTTP responses—like hitting ‘save’ on a webpage’s performance. For example, our /products page could load 10x faster with minimal code changes. It’s a zero-cost optimization that reduces server costs and improves user experience, especially for high-traffic routes. We’ll start with non-critical pages (e.g., dashboards) and expand to public-facing content. The risk is low—we can toggle it off if needed."

For Engineering: "spatie/laravel-responsecache is a drop-in middleware that caches entire responses (HTML/JSON) at the HTTP layer, bypassing Laravel’s request pipeline for cached hits. Key benefits:

  • Flexible caching: Choose between strict caching (e.g., CacheResponse::for(minutes(10))) or flexible caching (serve stale responses while refreshing in the background).
  • Granular control: Use PHP attributes (#[Cache], #[NoCache]) or route middleware for per-endpoint config.
  • Performance: Uses xxh128 hashing (faster than MD5) and integrates with Laravel’s cache drivers (Redis, database, etc.).
  • Maintenance: Actively developed (Laravel 13/PHP 8.5 support), with debug headers and tag-based invalidation.

Proposal: Pilot on our /analytics and /docs routes (low-risk, stale data acceptable). Expect ~50–90% reduction in backend load for cached routes. Tradeoff: Slight complexity in cache invalidation (but we’ll use tags for critical updates)."*

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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata