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)361.4k4[1 PRs](https://github.com/gchaincl/laravel-fragment-caching/pulls)1MITPHP

Since Apr 29Pushed 10y ago2 watchersCompare

[ 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 yesterday

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 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community16

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

4384d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dfcd2dc7b7b8f31d85e499f32772410cab73c28bf3db424cb5143c30fb563e33?d=identicon)[gchaincl](/maintainers/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.8k8.2M51](/packages/spatie-laravel-responsecache)[dragon-code/laravel-cache

An improved interface for working with cache

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

Laravel translation package with morph relationships and caching.

754.3k2](/packages/omaralalwi-lexi-translate)[michele-angioni/support

Support is a Laravel package which promotes the use of best practices and design patterns.

181.4k1](/packages/michele-angioni-support)[makbulut/laravel-aerospike

Aerospike cache driver for Laravel

102.2k](/packages/makbulut-laravel-aerospike)

PHPackages © 2026

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