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 Varnish Laravel Package

spatie/laravel-varnish

Integrate Varnish 4/5 with Laravel: add middleware to force-cache selected routes and flush/purge the Varnish cache from within your app. Includes simple configuration and supports Laravel and Lumen.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Performance Optimization: Enables seamless Varnish caching integration to reduce server load, improve response times, and lower infrastructure costs—critical for high-traffic applications (e.g., e-commerce, SaaS platforms, or content-heavy sites).
  • Build vs. Buy: Avoids reinventing Varnish integration from scratch, reducing dev time and maintenance overhead. Ideal for teams prioritizing speed and reliability over custom solutions.
  • Roadmap Alignment: Supports scaling initiatives by offloading static/dynamic content caching to Varnish, enabling future-proofing for traffic spikes (e.g., Black Friday sales, viral content).
  • Use Cases:
    • APIs: Cache responses for read-heavy endpoints (e.g., product catalogs, user profiles).
    • Dynamic Content: Bypass caching for authenticated routes (e.g., dashboards) while caching public-facing pages.
    • A/B Testing: Cache variations without recalculating logic on every request.
    • Edge Caching: Integrate with CDNs (e.g., Cloudflare) that use Varnish under the hood.

When to Consider This Package

  • Adopt When:

    • Running Laravel on Varnish 4/5 (confirmed compatibility).
    • Prioritizing low-latency responses for high-traffic routes (e.g., >10K RPS).
    • Needing granular cache control (e.g., per-route TTL, bypass rules).
    • Using Laravel middleware and wanting zero-config Varnish integration.
    • Budgeting for open-source support (MIT license) with optional Spatie sponsorship.
  • Look Elsewhere If:

    • Using Varnish 6+ (package lacks support; check for updates).
    • Requiring advanced caching logic (e.g., multi-level caching with Redis).
    • Needing enterprise-grade support (SLA, dedicated onboarding).
    • Already invested in a custom Varnish solution or other caching layers (e.g., Fastly, Nginx).
    • Dynamic content dominates (e.g., real-time apps like chat), making caching less impactful.

How to Pitch It (Stakeholders)

For Executives: "This package lets us leverage Varnish to cache Laravel responses automatically, cutting server costs and improving speed for our most critical routes—like product pages or APIs—with minimal dev effort. For example, [Company X] reduced their backend load by 60% after adopting Varnish, and this gives us the same leverage without hiring caching experts. The MIT license keeps costs low, and Spatie’s track record ensures reliability. We’re proposing a 2-week pilot to cache 3 high-traffic endpoints, with a goal to expand to 80% of read-heavy routes within 3 months."

For Engineering: *"Spatie’s laravel-varnish provides a battle-tested middleware to force Varnish caching for Laravel routes, plus a simple varnish()->flush() method to clear cache programmatically. Key benefits:

  • Zero-config for basic use: Just add the middleware to routes.
  • Flexible bypass rules: Exclude authenticated or dynamic routes via Laravel’s existing middleware stack.
  • Dev-friendly: Works with Laravel’s event system (e.g., CacheCleared hooks).
  • Lightweight: ~500 LOC, no external dependencies beyond Varnish. Tradeoff: Limited to Varnish 4/5, but we can mitigate this by planning an upgrade path if needed. Recommend testing with our top 5 traffic routes first."*
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport