All Projects → spatie → Laravel Partialcache

spatie / Laravel Partialcache

Licence: mit
Blade directive to cache rendered partials in laravel

Projects that are alternatives of or similar to Laravel Partialcache

Laravel Blink
Cache that expires in the blink of an eye
Stars: ✭ 114 (-44.39%)
Mutual labels:  cache, laravel, performance
Laravel Responsecache
Speed up a Laravel app by caching the entire response
Stars: ✭ 1,874 (+814.15%)
Mutual labels:  cache, laravel, performance
Api Restful Con Laravel Guia Definitiva
Repositorio para el código base del curso "API RESTful con Laravel - Guía Definitiva"
Stars: ✭ 95 (-53.66%)
Mutual labels:  cache, laravel
Laravel Cacheable
Rinvex Cacheable is a granular, intuitive, and fluent caching system for eloquent models. Simple, but yet powerful, plug-n-play with no hassle.
Stars: ✭ 107 (-47.8%)
Mutual labels:  cache, laravel
Quitnow Cache
A collection to store data for a given time
Stars: ✭ 109 (-46.83%)
Mutual labels:  cache, performance
Pomodoro
A simple WordPress translation cache
Stars: ✭ 47 (-77.07%)
Mutual labels:  cache, performance
Ansible Role Memcached
Ansible Role - Memcached
Stars: ✭ 54 (-73.66%)
Mutual labels:  cache, performance
Fast React Render
[DEPRECATED] Use last versions of React and Node.js for better performance
Stars: ✭ 102 (-50.24%)
Mutual labels:  cache, performance
Fragment Cache
WordPress plugin for partial and async caching.
Stars: ✭ 135 (-34.15%)
Mutual labels:  cache, performance
Aimeos
Integrated online shop based on Laravel 8 and the Aimeos e-commerce framework
Stars: ✭ 2,354 (+1048.29%)
Mutual labels:  laravel, performance
Htmlcache
Laravel middleware to cache the rendered html
Stars: ✭ 35 (-82.93%)
Mutual labels:  cache, laravel
Thinkgo
A lightweight MVC framework written in Go (Golang).
Stars: ✭ 184 (-10.24%)
Mutual labels:  cache, laravel
Laravel Couchbase
Couchbase providers for Laravel
Stars: ✭ 31 (-84.88%)
Mutual labels:  cache, laravel
Kirby3 Autoid
Automatic unique ID for Pages, Files and Structures including performant helpers to retrieve them. Bonus: Tiny-URL.
Stars: ✭ 58 (-71.71%)
Mutual labels:  cache, performance
Laravel Image Optimizer
Optimize images in your Laravel app
Stars: ✭ 873 (+325.85%)
Mutual labels:  laravel, performance
Easy Cache
a cache trait for Laravel to do cache eaily
Stars: ✭ 12 (-94.15%)
Mutual labels:  cache, laravel
Simple Cache
An easy to use Caching trait for Laravel's Eloquent Models.
Stars: ✭ 19 (-90.73%)
Mutual labels:  cache, laravel
Wordpress Rest Cache
WordPress Plugin to lazy cache HTTP requests in database and update via cron.
Stars: ✭ 8 (-96.1%)
Mutual labels:  cache, performance
Craft Blitz
Intelligent static page caching for creating lightning-fast sites with Craft CMS.
Stars: ✭ 118 (-42.44%)
Mutual labels:  cache, performance
Laravel Mix Preload
Add preload and prefetch links based your Mix manifest
Stars: ✭ 162 (-20.98%)
Mutual labels:  laravel, performance

🚨 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

Latest Version on Packagist Software License Quality Score StyleCI Total Downloads

This package provides a Blade directive for Laravel >=5.1 to cache rendered partials in Laravel.

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

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

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

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

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.

Credits

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.

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].