PHPackages                             reckless/blade-cache-directive - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. reckless/blade-cache-directive

ActiveLibrary[Templating &amp; Views](/categories/templating)

reckless/blade-cache-directive
==============================

Cache chunks of your Blade markup with ease.

02PHP

Since Apr 22Pushed 2y agoCompare

[ Source](https://github.com/RecklessAgency/blade-cache-directive)[ Packagist](https://packagist.org/packages/reckless/blade-cache-directive)[ RSS](/packages/reckless-blade-cache-directive/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Blade Cache Directive
=====================

[](#blade-cache-directive)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ce3785c68e5ec13f2daf520532ae6351fd9b36c73988f4b785ea039423510c36/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7279616e676a6368616e646c65722f626c6164652d63616368652d6469726563746976652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ryangjchandler/blade-cache-directive)[![GitHub Tests Action Status](https://camo.githubusercontent.com/74bfe2e0cac4810e0dab8c044e48039fc5f633d9ea507ea9f781ff24a3645789/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7279616e676a6368616e646c65722f626c6164652d63616368652d6469726563746976652f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/ryangjchandler/blade-cache-directive/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/97d38d60fdebf477bfca48eac4518380567aac253c4a0e4ee60adaec009d3a6b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7279616e676a6368616e646c65722f626c6164652d63616368652d6469726563746976652f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/ryangjchandler/blade-cache-directive/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/3842849b00127ce76be159df7a264699aab983f7838b8235ffe5bd87f3ac5a9b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7279616e676a6368616e646c65722f626c6164652d63616368652d6469726563746976652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ryangjchandler/blade-cache-directive)

Cache chunks of your Blade markup with ease.

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require ryangjchandler/blade-cache-directive
```

You can publish the config file with:

```
php artisan vendor:publish --provider="RyanChandler\BladeCacheDirective\BladeCacheDirectiveServiceProvider" --tag="blade-cache-directive-config"
```

This is the contents of the published config file:

```
return [

    'enabled' => env('BLADE_CACHE_DIRECTIVE_ENABLED', true),

    'ttl' => env('BLADE_CACHE_DIRECTIVE_TTL', 3600),

];
```

Usage
-----

[](#usage)

This package adds a new `@cache` Blade directive. It accepts 2 arguments - the cache key and a TTL.

```
@cache('current_time', 30)
    {{ now() }}
@endcache
```

When used inside of a Blade template, the content between the 2 directives will be cached using Laravel's application cache. If a TTL (in seconds) isn't provided, the default TTL of **1 hour** will be used instead.

If you want to cache the content for a particular model, i.e. a `User` model, you can use string interpolation to change the key.

```
@cache("user_profile_{$user->id}")
    {{ $user->name }}
@endcache
```

When a new user is passed to this view, a separate cache entry will be created.

### Disabling caching

[](#disabling-caching)

If you wish to disable caching when using the `@cache` directive (useful for local development and testing), you can set the `BLADE_CACHE_DIRECTIVE_ENABLED` environment variable to `false`.

Alternatively, publish the configuration file and modify the `enabled` entry accordingly.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ryan Chandler](https://github.com/ryangjchandler)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1214612?v=4)[Reckless](/maintainers/Reckless)[@Reckless](https://github.com/Reckless)

---

Top Contributors

[![ryangjchandler](https://avatars.githubusercontent.com/u/41837763?v=4)](https://github.com/ryangjchandler "ryangjchandler (15 commits)")[![brynj-digital](https://avatars.githubusercontent.com/u/13166627?v=4)](https://github.com/brynj-digital "brynj-digital (5 commits)")[![phpfour](https://avatars.githubusercontent.com/u/171715?v=4)](https://github.com/phpfour "phpfour (4 commits)")[![applyACS](https://avatars.githubusercontent.com/u/13115651?v=4)](https://github.com/applyACS "applyACS (2 commits)")[![yvesdaxmaz](https://avatars.githubusercontent.com/u/7295614?v=4)](https://github.com/yvesdaxmaz "yvesdaxmaz (1 commits)")[![bobclewell](https://avatars.githubusercontent.com/u/116818?v=4)](https://github.com/bobclewell "bobclewell (1 commits)")[![BrandonOldenhof](https://avatars.githubusercontent.com/u/42144260?v=4)](https://github.com/BrandonOldenhof "BrandonOldenhof (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")

### Embed Badge

![Health badge](/badges/reckless-blade-cache-directive/health.svg)

```
[![Health](https://phpackages.com/badges/reckless-blade-cache-directive/health.svg)](https://phpackages.com/packages/reckless-blade-cache-directive)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3851.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.1k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.3k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

282.2k](/packages/webkinder-sproutset)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
