Weave 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
Cache Plugin

Cache Plugin Laravel Package

saloonphp/cache-plugin

Cache plugin for Saloon adds response caching to your API integrations, storing HTTP responses so repeated requests are served from cache instead of hitting the network. Configure cache drivers, TTLs, and per-request rules to speed up your app.

View on GitHub
Deep Wiki
Context7

Official plugin for caching Saloon responses

Frequently asked questions about Cache Plugin
What is saloonphp/cache-plugin used for?
It is the official Saloon HTTP client plugin for caching responses through any PSR-16 cache store. It helps skip duplicate API calls, reduce latency, ease rate-limit pressure, and speed up repeated requests. It fits read-heavy or expensive idempotent API calls in PHP applications.
How do I install saloonphp/cache-plugin in a Laravel app?
Install it with Composer using composer require saloonphp/cache-plugin. Your app must meet the plugin requirements, including Saloon v4+ and PHP 8.1+, and you need a PSR-16 compatible cache store. Then configure caching on your Saloon requests or connector with withCache rather than adding Laravel-specific glue.
Does saloonphp/cache-plugin support Laravel 10, 11, or 12?
The plugin is framework-agnostic and does not ship Laravel-specific version constraints. Compatibility depends on your Laravel app satisfying Saloon v4+ and PHP 8.1+ requirements and providing a PSR-16 cache store. Check Composer resolution for your exact Laravel release before adopting it.
How do I configure cache keys and TTLs with the Saloon cache plugin?
Configure caching on the Saloon request or connector with withCache and use a deterministic key derivation function for dynamic query parameters. Set a TTL that matches how fresh the API response must be. Keep key generation consistent so withCache and clearCache can reliably target the same cache entry.
How does clearCache work in saloonphp/cache-plugin v3.3.0?
clearCache purges a cached response without sending a request to the origin API. It was added as an additive method in v3.3.0 and is useful after POST, PUT, or DELETE flows, webhook listeners, or other write-then-invalidate paths. You must use the same key derivation approach as withCache for reliable invalidation.
Is saloonphp/cache-plugin safe for production API caching?
It is lightweight and low-coupling, but the evaluation notes it is still lightly tested at scale. Production concerns remain around stale data, cache stampedes, read-during-write races, and distributed cache partitions. Use atomic cache operations where possible, add monitoring for hit and miss behavior, and plan fallback behavior if the cache backend fails.
How do I test Saloon requests that use the cache plugin?
Mock the PSR-16 cache in unit tests and assert cache hits, misses, and clearCache behavior. Test key generation with dynamic query parameters such as /users?role=admin so cached and purged entries match. Add integration tests with a real PSR-16 store for the cache paths that matter most.
What are alternatives to saloonphp/cache-plugin for caching API responses?
For simple cases, custom Saloon middleware or manual PSR-16 caching may be enough. Saloon retry logic addresses failures rather than response caching, and OPcache caches PHP bytecode rather than HTTP responses. For shared HTTP caching, a reverse proxy such as Varnish can be more maintainable long-term.
Does saloonphp/cache-plugin work with Redis and other PSR-16 cache stores?
Yes, it works through any PSR-16 cache store, so Redis-backed PSR-16 adapters and libraries such as predis/predis or php-cache/cache-item-pool can be used if they satisfy PSR-16. The plugin does not solve Redis cluster partitions or distributed cache edge cases for you. Confirm your store behavior for TTLs and atomic operations before production use.
What Saloon version does saloonphp/cache-plugin require?
Saloon v4+ is mandatory for saloonphp/cache-plugin since v3.1.0, so older Saloon v3 applications need a dependency upgrade or version pinning. The plugin does not provide a Saloon v3 to v4 migration path. Verify your composer.json constraints before adding the cache plugin to an existing Saloon codebase.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo