spatie/laravel-flexible-cache-polyfill
Polyfill for Laravel 10 that adds Cache::flexible() (introduced in Laravel 11). Implements stale-while-revalidate caching so expired values can be served immediately while recalculation runs in the background, avoiding slow responses.
Cache::flexible() exists).For Executives: "This lightweight package lets us adopt Laravel 11’s stale-while-revalidate caching in our Laravel 10 app without a costly upgrade. It’s a 5-minute install that could cut response times for [X high-impact endpoint] by serving stale data while refreshing it in the background—like how Netflix shows you a loading spinner but keeps playing the video. No risk, just performance gains."
For Engineering: *"Spatie’s polyfill gives us Cache::flexible() for Laravel 10, enabling SWR for endpoints where stale data is tolerable (e.g., user dashboards, analytics). It’s:
For Developers:
*"Need SWR in Laravel 10? This package adds Cache::flexible() with a single line:
use Spatie\FlexibleCache\FlexibleCache;
$value = Cache::flexible('key', 10, fn() => $expensiveOperation, 5);
10s while regenerating in 5s.Cache::remember for non-critical data (e.g., cached reports).How can I help you explore Laravel packages today?