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

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

spatie/laravel-partialcache
===========================

Blade directive to cache rendered partials in laravel

1.3.0(8y ago)195236.8k↓28.8%30MITPHPPHP &gt;=5.5.0

Since Jun 17Pushed 7y ago8 watchersCompare

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

READMEChangelog (8)Dependencies (2)Versions (10)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/c9883aceb2b715c7d027fb8f5016f64a6ef4944cb2ee771707cb96b48d145ea5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d7061727469616c63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-partialcache)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Quality Score](https://camo.githubusercontent.com/60ab8b1f696eee9b2c943573ce6c79634e3e6b6a745d2a67d3f1d47dc8398173/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f6c61726176656c2d7061727469616c63616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/laravel-partialcache)[![StyleCI](https://camo.githubusercontent.com/1a51be475d568e84baa8172c2b6ec2aa3e942a48372499a52c97ad59ef0d7779/68747470733a2f2f7374796c6563692e696f2f7265706f732f33373538393631352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/37589615)[![Total Downloads](https://camo.githubusercontent.com/7637857ff93b02ea753fb9bc38ca341f934ab7f4c97a45dfc2afcac07a350304/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d7061727469616c63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/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 spatie/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' => [
  ...
  Spatie\PartialCache\PartialCacheServiceProvider::class,
],

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

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

Optionally publish the config files:

```
$ php artisan vendor:publish --provider="Spatie\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 three options specified in the config file:

- `partialcache.enabled`: Fully enable or disable the cache. Defaults to `true`.
- `partialcache.directive`: The name of the blade directive to register. Defaults to `cache`.
- `partialcache.key`: The base key that used for cache entries. Defaults to `partialcache`.
- `partialcache.default_duration`: The default cache duration in minutes, set `null` to remember forever. Defaults to `null`.

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

43

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 58.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 ~129 days

Recently: every ~140 days

Total

9

Last Release

2954d ago

Major Versions

0.1 → 1.0.02015-06-30

### Community

Maintainers

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

---

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)")[![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)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (1 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)")

---

Tags

cachelaravelperformancephpspatiecacheviewpartial

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[eftec/bladeone

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

8208.4M87](/packages/eftec-bladeone)[spatie/laravel-view-models

View models in Laravel

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

Simple view presenters

8643.4M46](/packages/laracasts-presenter)[spatie/laravel-blade-comments

Add debug comments to your rendered output

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

Smarty template engine for Laravel and Lumen

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

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

7526.3M230](/packages/laminas-laminas-view)

PHPackages © 2026

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