spatie/laravel-partialcache
Abandoned package that adds a Blade @cache directive to cache rendered partial HTML in Laravel (5.1+). Supports passing view data, setting cache duration, custom keys, and cache tags, with optional facade/config publishing.
@partialCache) to cache rendered partials, which is a valid solution for reducing redundant rendering of static or semi-static components (e.g., headers, footers, sidebars, or dynamic-but-infrequently-changing content).Cache facade). If the application already uses Laravel’s built-in caching (e.g., Redis, Memcached, file-based), this package can integrate seamlessly.Cache facade, so it supports any cache driver configured in config/cache.php (Redis, database, file, etc.).@cache directives or manual caching), the risk may not justify adoption.@cache directive or packages like laravel-view-caching (active maintenance) may offer better support.Cache::forget()) aligns with partial updates.@partialCache directive on a non-critical partial (e.g., a footer).Cache facade.@partialCache or similar directives. Rename or namespace if needed.composer require spatie/laravel-partialcache
config/app.php.@partialCache:
@partialCache('footer', '1 hour')
@include('partials.footer')
@endpartialCache
staudenmeir/laravel-view-caching) if partial caching becomes a core feature.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Cache driver failure (e.g., Redis down) | Partial rendering falls back to full render, increasing load. | Use a fallback cache driver (e.g., file-based). |
| Cache stampede (short TTL + high traffic) | Server overload during cache regeneration. | Implement cache warming or longer TTLs. |
| Laravel upgrade breaks compatibility | Package stops working. | Fork and maintain compatibility patches. |
| Incorrect cache invalidation | Stale content displayed. | Use explicit cache tags/keys for granular control. |
| Fork abandonment by internal team | Unpatched vulnerabilities. | Assign long-term ownership or switch to a maintained package. |
@partialCache directive).How can I help you explore Laravel packages today?