PHPackages                             julienmru/laravel-partialcache - 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. julienmru/laravel-partialcache

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

julienmru/laravel-partialcache
==============================

Blade directive to cache rendered partials in laravel

1.5.0(3y ago)014MITPHPPHP &gt;=7.2.5

Since Mar 17Pushed 3y agoCompare

[ Source](https://github.com/julienmru/laravel-partialcache)[ Packagist](https://packagist.org/packages/julienmru/laravel-partialcache)[ Docs](https://github.com/julienmru/laravel-partialcache)[ RSS](/packages/julienmru-laravel-partialcache/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

🚨 THIS PACKAGE HAS BEEN ABANDONED 🚨

We don't use this package anymore in our own projects and cannot justify the time needed to maintain it anymore. That's why we have chosen to abandon it. Feel free to fork our code and maintain your own copy.

Laravel Cache Partial Blade Directive
=====================================

[](#laravel-cache-partial-blade-directive)

[![Latest Version on Packagist](https://camo.githubusercontent.com/80548f4684cdd5009926bea17e54d59948c1527f6bde75c9124c9d98f2e550fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a756c69656e6d72752f6c61726176656c2d7061727469616c63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/julienmru/laravel-partialcache)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Quality Score](https://camo.githubusercontent.com/7cbc6f9ac81a92bca5b35e2843ad43e173b440a3ed438300d2961d4a862c7688/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6a756c69656e6d72752f6c61726176656c2d7061727469616c63616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/julienmru/laravel-partialcache)[![StyleCI](https://camo.githubusercontent.com/1a51be475d568e84baa8172c2b6ec2aa3e942a48372499a52c97ad59ef0d7779/68747470733a2f2f7374796c6563692e696f2f7265706f732f33373538393631352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/37589615)[![Total Downloads](https://camo.githubusercontent.com/b1a952c25248841646e932ef3a5bb8c35a277284085a89794a105c73cb2c06b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a756c69656e6d72752f6c61726176656c2d7061727469616c63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/julienmru/laravel-partialcache)

This package provides a Blade directive for Laravel &gt;=5.1 to cache rendered partials in Laravel.

Install
-------

[](#install)

You can install the package via Composer:

```
$ composer require julienmru/laravel-partialcache
```

In Laravel 5.5 the package's service provider and facade will be registered automatically. In older versions of Laravel, you must register them manually:

```
// config/app.php

'providers' => [
  ...
  JulienMru\PartialCache\PartialCacheServiceProvider::class,
],

'aliases' => [
  ...
  'PartialCache' => JulienMru\PartialCache\PartialCacheFacade::class,
],
```

*The facade is optional, but the rest of this guide assumes you're using it.*

Publish the config files:

```
$ php artisan vendor:publish --provider="JulienMru\PartialCache\PartialCacheServiceProvider"
```

Usage
-----

[](#usage)

The package registers a blade directive, `@cache`. The cache directive accepts the same arguments as `@include`, plus optional parameters for the amount of minutes a view should be cached for, a key unique to the rendered view, and a cache tag for the rendered view. If no minutes are provided, the view will be remembered until you manually remove it from the cache.

Note that this caches the rendered html, not the rendered php like blade's default view caching.

```
{{-- Simple example --}}
@cache('footer.section.partial')

{{-- With extra view data --}}
@cache('products.card', ['product' => $category->products->first()])

{{-- For a certain time --}}
{{-- (cache will invalidate in 60 minutes in this example, set null to remember forever) --}}
@cache('homepage.news', null, 60)

{{-- With an added key (cache entry will be partialcache.user.profile.{$user->id}) --}}
@cache('user.profile', null, null, $user->id)

{{-- With an added tag (only supported by memcached and others) }}
@cache('user.profile', null, null, $user->id, 'userprofiles')

{{-- With array of tags (only supported by memcached and others) }}
@cache('user.profile', null, null, $user->id, ['user', 'profile', 'location'])

```

### Clearing The PartialCache

[](#clearing-the-partialcache)

You can forget a partialcache entry with `PartialCache::forget($view, $key)`.

```
PartialCache::forget('user.profile', $user->id);
```

If you have used @cache on an entry along with tags and your cache driver supports them (like memcached and other), you need to use the same tags to forget the entry.

```
// With an added tag
PartialCache::forget('user.profile', $user->id, 'userprofiles');

// With array of tags
PartialCache::forget('user.profile', $user->id, ['user', 'profile', 'location']);
```

If you want to flush all entries, you'll need to either call `PartialCache::flush()` (note: this is only supported by drivers that support tags), or clear your entire cache.

### Configuration

[](#configuration)

Configuration isn't necessary, but there are environement variables you can use:

- `PARTIAL_CACHE_ENABLED`: Fully enable or disable the cache. Defaults to `true`.
- `PARTIAL_CACHE_DIRECTIVE`: The name of the blade directive to register. Defaults to `cache`.
- `PARTIAL_CACHE_KEY`: The base key that used for cache entries. Defaults to `partialcache`.
- `PARTIAL_CACHE_DEFAULT_DURATION`: The default cache duration in minutes, set `null` to remember forever. Defaults to `null`.
- `PARTIAL_CACHE_DRIVER`: The cache store that should be used to store requests. Defaults to `file`.

Change log
----------

[](#change-log)

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

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

[](#contributing)

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

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).

Credits
-------

[](#credits)

- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

Support us
----------

[](#support-us)

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/spatie). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License
-------

[](#license)

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

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.2% 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.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

1192d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2283306?v=4)[Julien Tessier](/maintainers/julienmru)[@julienmru](https://github.com/julienmru)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (32 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (13 commits)")[![julienmru](https://avatars.githubusercontent.com/u/2283306?v=4)](https://github.com/julienmru "julienmru (4 commits)")[![jfeid](https://avatars.githubusercontent.com/u/1190470?v=4)](https://github.com/jfeid "jfeid (3 commits)")[![hadefication](https://avatars.githubusercontent.com/u/6673244?v=4)](https://github.com/hadefication "hadefication (2 commits)")[![Tjoosten](https://avatars.githubusercontent.com/u/5157609?v=4)](https://github.com/Tjoosten "Tjoosten (1 commits)")[![billmn](https://avatars.githubusercontent.com/u/779534?v=4)](https://github.com/billmn "billmn (1 commits)")[![dpatou](https://avatars.githubusercontent.com/u/1031185?v=4)](https://github.com/dpatou "dpatou (1 commits)")[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (1 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (1 commits)")

---

Tags

spatiecacheviewpartialjulienmru

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/julienmru-laravel-partialcache/health.svg)

```
[![Health](https://phpackages.com/badges/julienmru-laravel-partialcache/health.svg)](https://phpackages.com/packages/julienmru-laravel-partialcache)
```

###  Alternatives

[eftec/bladeone

The standalone version Blade Template Engine from Laravel in a single php file

8259.3M103](/packages/eftec-bladeone)[spatie/laravel-view-models

View models in Laravel

1.1k3.6M16](/packages/spatie-laravel-view-models)[laracasts/presenter

Simple view presenters

8653.6M47](/packages/laracasts-presenter)[spatie/laravel-blade-comments

Add debug comments to your rendered output

179332.0k](/packages/spatie-laravel-blade-comments)[ytake/laravel-smarty

Smarty template engine for Laravel and Lumen

85406.6k](/packages/ytake-laravel-smarty)[laminas/laminas-view

Fast and type safe HTML templating library with a flexible plugin system supporting multistep template composition

7527.7M260](/packages/laminas-laminas-view)

PHPackages © 2026

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