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

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

pixxet/laravel-partialcache
===========================

Laravel Cache Partial Blade Directive

v1.0.0(6y ago)137.0k1MITPHPPHP &gt;=7.1CI failing

Since Jan 8Pushed 6y ago2 watchersCompare

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

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

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

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/9576897ea1bbb4be8a9cafaf26fb8ea96c12ea82fc3e948d2ff643575f7ad708/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7069787865742f6c61726176656c2d7061727469616c63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pixxet/laravel-partialcache)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![StyleCI](https://camo.githubusercontent.com/dbc1603a43d1f865a1377870495d19f8e2734a20a0dff8d8eac7243d71267759/68747470733a2f2f7374796c6563692e696f2f7265706f732f3233323035383431342f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/232058414)[![Total Downloads](https://camo.githubusercontent.com/30ecb6c974403efc8e04a5ff0f54b0c3e0e50117bf5330f7953d69a0edd8edff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7069787865742f6c61726176656c2d7061727469616c63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pixxet/laravel-partialcache)

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

Install
-------

[](#install)

You can install the package via Composer:

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

In Laravel 6.0 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' => [
  ...
  Pixxet\PartialCache\PartialCacheServiceProvider::class,
],

'aliases' => [
  ...
  'PartialCache' => Pixxet\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="Pixxet\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()])

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

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

{{-- If template exists --}}
{{-- Just like the usual includeIf directive add "If" to the cache (or your custom directive) to cache partial only if the template exists --}}
@cacheIf('footer.section.partial')

{{-- When boolean true --}}
{{-- Just like the usual includeWhen directive add "When" to the cache (or your custom directive) to cache partial depending on a given boolean condition --}}
@cacheWhen($isPrintable !== true, 'footer.section.partial')

```

### Clearing The PartialCache

[](#clearing-the-partialcache)

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

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

If you want to flush all entries, you'll need to 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.

Credits
-------

[](#credits)

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

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

2317d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48be3e770dee61df7b7aadd1049cb7179de9041805a9fce958367d12e6ec9cc2?d=identicon)[pixxet](/maintainers/pixxet)

---

Tags

cacheviewpartial

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[eftec/bladeone

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

8208.4M87](/packages/eftec-bladeone)[laracasts/presenter

Simple view presenters

8643.4M46](/packages/laracasts-presenter)[jenssegers/blade

The standalone version of Laravel's Blade templating engine for use outside of Laravel.

8661.2M109](/packages/jenssegers-blade)[backpack/generators

Generate files for laravel projects

3122.6M18](/packages/backpack-generators)[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)
