microweber-packages / microweber-blade-cache
Blade @cache / @endcache directive for Laravel. Cache expensive Blade fragments with tags and expiration.
Package info
github.com/microweber-packages/microweber-blade-cache
pkg:composer/microweber-packages/microweber-blade-cache
v1.0.0
2026-11-03 11:17 UTC
Requires
- php: ^8.1
- illuminate/cache: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- illuminate/view: ^10.0|^11.0|^12.0|^13.0
- microweber-packages/microweber-package: *
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0|^11.0
- phpunit/phpunit: ^10.0|^11.0|^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
- microweber-packages/blade-cache: *
This package is auto-updated.
Last update: 2026-11-03 15:25:17 UTC
README
Cache expensive Blade fragments with a simple @cache / @endcache directive.
Installation
composer require microweber-packages/microweber-blade-cache
The service provider is auto-discovered.
Usage
@cache('sidebar', ['navigation', 'menus'], 3600) {{-- expensive rendering --}} @endcache
Arguments
| # | Name | Type | Default | Description |
|---|---|---|---|---|
| 1 | key | string | required | Unique cache key |
| 2 | tags | array | [] |
Cache tags for invalidation |
| 3 | ttl | int|null | config default | Seconds until expiry |
Configuration
Publish the config:
php artisan vendor:publish --tag=blade-cache-config
| Key | Env | Default | Description |
|---|---|---|---|
enabled |
BLADE_CACHE_ENABLED |
true |
Toggle caching |
ttl |
BLADE_CACHE_TTL |
3600 |
Default TTL in seconds |
store |
BLADE_CACHE_STORE |
null |
Cache store (null = default) |
Programmatic API
$service = app(\MicroweberPackages\BladeCache\BladeCacheService::class); $service->put('key', '<html>', ['tag'], 600); $service->get('key', ['tag']); $service->forget('key', ['tag']); $service->flush(['tag']);
License
MIT