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

Cache Plugin Laravel Package

saloonphp/cache-plugin

Laravel/PHP caching plugin for Saloon HTTP client. Cache API responses with configurable drivers, TTLs, and cache keys to reduce requests and speed up integrations. Supports per-request caching controls and easy setup for existing Saloon connectors.

Deep Wiki
Context7

🤠 Official plugin for caching Saloon responses

Frequently asked questions about Cache Plugin
How do I cache API responses in Saloon using this plugin?
Use the `withCache()` method on your Saloon connector or apply the `CacheMiddleware` in your middleware stack. Configure a PSR-16 cache driver (e.g., Redis) and set a TTL for cached responses. Example: `$connector->withCache()->fetch()`.
Which Laravel versions and Saloon versions does this plugin support?
The plugin requires Saloon v4+ and PHP 8.1+. It’s framework-agnostic but designed for Laravel apps using Saloon. Check the `composer.json` constraints for exact Saloon version requirements, as it may not support older Laravel versions.
Can I customize cache keys for different API endpoints?
Yes, you can override the default cache key generation by implementing a custom `CacheKeyGenerator` class. This is useful for dynamic endpoints where query parameters or headers should influence the cache key.
What happens if the cache fails during a request?
The plugin defaults to bypassing the cache and making the HTTP request if the cache fails. You can configure a fallback strategy, such as retrying or logging the failure, but the request will proceed without cached data.
Does this plugin support cache invalidation for mutable data?
The plugin uses TTL-based invalidation by default. For mutable data, you’ll need to manually invalidate cache keys (e.g., via a webhook or cron job) or implement event-driven invalidation logic in your application.
How do I test this plugin in a Laravel application?
Mock the PSR-16 cache interface in your tests using a library like `mockery` or Laravel’s `Cache` facade. Test both cache hits and misses to ensure your logic handles stale data and failures gracefully.
Is Redis the only supported cache backend?
No, the plugin supports any PSR-16 compliant cache, including Memcached, APCu, or filesystem caching. Install the appropriate driver (e.g., `predis/predis` for Redis) and configure it in your Laravel cache config.
Will this plugin work with Laravel’s built-in cache system?
Yes, you can use Laravel’s cache drivers (e.g., Redis, database) as long as they implement PSR-16. Configure the plugin to use Laravel’s cache facade or a custom PSR-16 adapter.
Are there performance concerns with distributed caching?
Distributed caches like Redis can introduce latency or race conditions if not configured properly. Use atomic operations (e.g., `remember()`) and monitor cache hit/miss rates to optimize TTLs and avoid stampedes.
What are the alternatives to this plugin for caching Saloon responses?
Alternatives include Saloon’s built-in retry logic for transient failures, Laravel’s HTTP client with middleware, or a reverse proxy like Varnish. For simple cases, OPcache may suffice, but this plugin offers dedicated caching for HTTP responses.
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