PHPackages                             gchaincl/laravel-fragment-caching - 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. [Caching](/categories/caching)
4. /
5. gchaincl/laravel-fragment-caching

AbandonedArchivedLibrary[Caching](/categories/caching)

gchaincl/laravel-fragment-caching
=================================

Fragment Caching support helper

v0.0.1(12y ago)341.4k4[1 issues](https://github.com/gchaincl/laravel-fragment-caching/issues)[1 PRs](https://github.com/gchaincl/laravel-fragment-caching/pulls)1MITPHP

Since Apr 29Pushed 10y agoCompare

[ Source](https://github.com/gchaincl/laravel-fragment-caching)[ Packagist](https://packagist.org/packages/gchaincl/laravel-fragment-caching)[ RSS](/packages/gchaincl-laravel-fragment-caching/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (1)

Not supported [![No Maintenance Intended](https://camo.githubusercontent.com/d904056147052e22d8e1c7f46bb50293ed2aeb4c43ead9a2d0cf7a48b46d0562/687474703a2f2f756e6d61696e7461696e65642e746563682f62616467652e737667)](http://unmaintained.tech/)
===============================================================================================================================================================================================================================================

[](#not-supported-)

This project is not supported anymore, you can try [matryoshka](https://github.com/laracasts/matryoshka) instead.

laravel-fragment-caching
========================

[](#laravel-fragment-caching)

Add a Fragment caching support helper. [Blog post](http://gustaf.espontanea.io/blog/2014/02/09/laravel-fragment-caching)

Installation
============

[](#installation)

Run: `composer require gchaincl/laravel-fragment-caching:dev-master`or

- add: `"require": { "gchaincl/laravel-fragment-caching": "dev-master" }, `to composer.json
- run: `composer install`
- add: The following to your `app/config/app.php`

```
$providers => array(
  ...
 	'Gchaincl\LaravelFragmentCaching\ViewServiceProvider',
)
```

Usage
=====

[](#usage)

In your view:

```

@foreach ($posts as $post)

@cache("post" . $post->id)
     {{ link_to_route('post.show', $post->title, $post->id) }} ({{ $post->user->username }})
@endcache

@endforeach

```

First time we load that view, Framework will run 3 queries:

```
select * from "posts"
select * from "users" where "users"."id" = '5' limit 1
select * from "users" where "users"."id" = '5' limit 1
```

Second time, as fragments are already cached, there will be just one query:

```
select * from "posts"
```

Conditional caching
===================

[](#conditional-caching)

In situations where you don't always want to cache a block you can use `@cacheif($condition, $cacheId)`

```
{{-- Only use the cache for guests, admins will always get content rendered from the template --}}
@cacheif( Auth::guest(), "post" . $post->id)
     {{ link_to_route('post.show', $post->title, $post->id) }} (@if (Auth::guest()) {{ $post->user->username }} @else {{ $post->user->email }} @endif)
@endcacheif
```

Tip
---

[](#tip)

To update view rendering on model changes, you should expire your fragments:

```
// app/model/Post.php

class Post extends Eloquent {

    public static function boot() {
        parent::boot();
        static::updated(function($model) {
            Cache::forget("post" . $model->id);
        });
    }
}
```

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

4479d ago

### Community

Maintainers

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

---

Top Contributors

[![thomas-brx](https://avatars.githubusercontent.com/u/361840?v=4)](https://github.com/thomas-brx "thomas-brx (6 commits)")[![jvdanilo](https://avatars.githubusercontent.com/u/6813993?v=4)](https://github.com/jvdanilo "jvdanilo (3 commits)")[![assertchris](https://avatars.githubusercontent.com/u/200609?v=4)](https://github.com/assertchris "assertchris (1 commits)")

---

Tags

laravelhelpercachefragment

### Embed Badge

![Health badge](/badges/gchaincl-laravel-fragment-caching/health.svg)

```
[![Health](https://phpackages.com/badges/gchaincl-laravel-fragment-caching/health.svg)](https://phpackages.com/packages/gchaincl-laravel-fragment-caching)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.3M74](/packages/spatie-laravel-responsecache)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k161.4k2](/packages/mike-bronner-laravel-model-caching)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[dragon-code/laravel-cache

An improved interface for working with cache

7146.5k10](/packages/dragon-code-laravel-cache)[omaralalwi/lexi-translate

Laravel translation package with morph relationships and caching.

7318.8k8](/packages/omaralalwi-lexi-translate)

PHPackages © 2026

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