| Package Data | |
|---|---|
| Maintainer Username: | Perturbatio |
| Maintainer Contact: | bertpotato@gmail.com (Kris Kelly) |
| Package Create Date: | 2016-09-15 |
| Package Last Update: | 2022-12-28 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-25 03:02:01 |
| Package Statistics | |
|---|---|
| Total Downloads: | 15,536 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 2 |
| Total Watchers: | 1 |
| Total Forks: | 1 |
| Total Open Issues: | 0 |
This package is intended to allow you to cache portions of a web page by marking them using blade directives.
You can specify how long the partial will be cached for as well as naming it (to allow you to invalidate it if needed).
Nesting cacheTags is also possible, meaning that inner content will be cached at least as long as the outer cache is
Install it as a composer package with:
composer require perturbatio/cachetags
Add Perturbatio\CacheTags\CacheTagsProvider::class to your config/app.php providers array
Add 'CacheTags' => Perturbatio\CacheTags\CacheTags::class to your aliases
Then publish the config file with php artisan vendor:publish --tag=config this will create a cachetag.php config file in /config
@cachetagStart('super-cool-widget', 15) <!-- widget cached for 15 minutes -->
<?=superCoolWidgetThatTakesTooLongToGenerate();?>
@cachetagStart('other-cool-widget', 'forever') <!-- widget cached until something clears it, nested inside the outer cache -->
<?=otherCoolWidgetThatTakesTooLongToGenerate();?>
@cachetagEnd()
@cachetagEnd()
if ( cachetagHas('super-cool-widget') ){
echo cachetagGet('super-cool-widget');
} else {
cachetagStart('super-cool-widget', 15);
echo superCoolWidgetThatTakesTooLongToGenerate();
if ( cachetagHas('other-cool-widget') ){
echo cachetagGet('other-cool-widget');
} else {
cachetagStart('other-cool-widget', 'forever'); //widget cached until something clears it, nested inside the outer cache
echo otherCoolWidgetThatTakesTooLongToGenerate();
echo cachetagEnd();
}
echo cachetagEnd();
}
@cachetagClear('super-cool-widget')
//clear the cache for a specific key
cachetagClear('super-cool-widget');
if ( $otherCoolWidgetNeedsCacheInvalidated ){ //conditionally clear the
cachetagClear('other-cool-widget');
}