Download the PHP package swiss-devjoy/blade-staticcache-directive without Composer
On this page you can find all versions of the php package swiss-devjoy/blade-staticcache-directive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download swiss-devjoy/blade-staticcache-directive
More information about swiss-devjoy/blade-staticcache-directive
Files in swiss-devjoy/blade-staticcache-directive
Package blade-staticcache-directive
Short Description Put chunks of your Blade template into immutable static cache files
License MIT
Homepage https://github.com/swiss-devjoy/blade-staticcache-directive
Informations about the package blade-staticcache-directive
Put chunks of your Blade template into immutable static cache files
Increase performance by putting chunks of your Blade template into immutable static cache files. This package provides a directive for Blade templates that allows you to easily create static cache files for specific sections of your views. With OPCache enabled, this can significantly reduce the time it takes to render your views, especially for large and complex templates.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
To clear the cache you can run the following command:
To include some additional stats in your response about cached/uncached blade chunks, you can use the provided middleware:
For laravel 11.x and newer:
Add the middleware definition to the bootstrap app.
For laravel 10.x and earlier:
Add the middleware definition to the http kernel.
Cache Profile
The cache profile is responsible for generating the unique key for the cache entry. By default, it uses the \SwissDevjoy\BladeStaticcacheDirective\CacheProfile
class, which generates a key based on the cache key parameter passed to the @staticcache
directive AND the current locale.
Inspiration
The main idea came from a tweet (https://x.com/dgurock/status/1577314908982706176) and the following package: https://github.com/ryangjchandler/blade-cache-directive
I did some basic benchmarks with a huge template and a lot of data.
Using Ryan's package and redis
as a cache driver, I got 85 req/s.
Using Ryan's package and file
as a cache driver, I got 99 req/s.
Using my package, I got 110 req/s.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Dimitri König
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of blade-staticcache-directive with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0||^12.0