New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

jangaraev/laravel-blade-cache

Handy package to cache blade files
874 3
Install
composer require jangaraev/laravel-blade-cache
Latest Version:1.0.4
PHP:>=8.0
Laravel:8 – 13
Last Updated:Oct 5, 2026
Links: GitHub  ·  Packagist
Maintainer: jangaraev

laravel-blade-cache

A small package to cache blade views. It caches the whole contents of rendered blade file as a regular cache item and then just outputs it from cache during next requests.

It gives a significant speed & memory usage improvement in case if a large dataset is to be processed in blade files, typically a large Eloquent collection with lots of relationships loaded.

Installation

$ composer require jangaraev/laravel-blade-cache

Usage

In Blade files call the @cache view helper where needed.

Arguments:

  1. $view - view name
  2. $ttl - cache ttl, optional, default is one hour (60)
// before
@include('homepage.categories')

// after
@cache('homepage.categories', 30)

Then you should use a view composer to pass the data to view: https://laravel.com/docs/views#view-composers

For example, in your AppServiceProvider:


use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    // ...
    
    public function boot()
    {
        View::composer('homepage.categories', function (\Illuminate\View\View $view) {
            $view->with('records', \App\Repositories\Foo::get());
        });
        
        View::composer('components.listings', function (\Illuminate\View\View $view) {
            $view->with([
                'block_title' => __('titles.new'),
                'listings' => \App\Models\FooBar::getRecent(),
                'seeMore' => route('listings.latest')
            ]);
        });
}

License

Package is an open-sourced laravel package licensed under the MIT license.

Related Packages

ngangchill/blade

This is a standalone package for laravel blade with some extra function such as...

33 0
esemve/vanillacache

Powerful cache engine for Laravel 5

18 1
kharanenka/laravel-cache-helper

Cache helper for default laravel cache class

52,988 2
perturbatio/cachetags

Provides a partial caching mechanism for use with Laravel's Blade templating lan...

15,536 2
andynoelker/laravel-5-view-generator

Adds a Blade view generator to Laravel 5.

964 5

Version History

Version Released PHP Laravel License
1.0.4 >=8.0 ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
1.0.3 >=8.0 ^8.0|^9.0|^10.0|^11.0
v1.0.2 >=8.0 ^8.0|^9.0
v1.0.1 >=8.0 ^8.0|^9.0
v1.0 >=8.0 ^8.0|^9.0