Download the PHP package mvaliolahi/blaze without Composer
On this page you can find all versions of the php package mvaliolahi/blaze. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mvaliolahi/blaze
More information about mvaliolahi/blaze
Files in mvaliolahi/blaze
Package blaze
Short Description A Laravel package for speedup laravel routes by generate an static version of them.
License
Informations about the package blaze
Blaze - Accelerate Laravel with Rocket-Like Speed
Introduction
Blaze is a versatile package that revolutionizes the way you build websites in Laravel. By seamlessly combining dynamic and static content generation, Blaze empowers developers to create high-performance websites with ease. With Blaze, you can achieve an average response time of just 4 milliseconds, ensuring lightning-fast performance for your applications. This comprehensive README.md will guide you through the setup and usage of Blaze, enabling you to harness its full potential for building dynamic and static websites in Laravel.
Here's a more detailed diagram illustrating how Blaze interacts with Laravel and Nginx for dynamic and static content generation, along with cache invalidation:
- HTTP requests are initially received by Nginx.
- Nginx forwards dynamic requests to the Laravel application.
- Laravel processes dynamic routes and generates responses for dynamic content.
- Responses are served to clients directly or cached by Blaze as static files.
- For cache hits, Nginx serves static files directly, bypassing Laravel for improved performance.
- If a cache miss occurs, Blaze generates cache files for the dynamic content and stores them.
- Cached files are served by Nginx for subsequent requests until invalidated.
- Cache invalidation can occur due to model changes, custom events, or other triggers.
- Upon invalidation, Blaze removes outdated cache files to ensure fresh content delivery.
- The cycle continues, providing a seamless blend of dynamic and static content delivery for optimal performance.
Note: having nginx is not required but using the provided config can significantly improve response time.
Features
- Dynamic-Static Fusion: Blaze seamlessly integrates dynamic and static content generation, offering the best of both worlds for website performance and scalability.
- Automatic Content Rendering: Blaze automates content rendering and caching, ensuring lightning-fast response times and optimal user experience.
- Flexible Configuration: Customize Blaze to fit your project's requirements with its flexible configuration options and intuitive design.
Getting Started
1. Installation
- Install Blaze via Composer:
2. Configuration
- Add
blaze_idto yourEncryptCookiesmiddleware like this:
You should also add @blaze directive before the body tag ends for handle csrf.
3. Adding Blaze to Routes
- Blaze introduces two types of caching:
privateandpublic.- Private Routes: These routes are personalized and may display user-specific content. Use the
blaze:privatemiddleware to mark routes as private. - Public Routes: These routes are static and serve the same content to all users. Use the
blaze:publicmiddleware to mark routes as public.
- Private Routes: These routes are personalized and may display user-specific content. Use the
-
Example:
Difference between
blaze:privateandblaze:public- Private Routes (
blaze:private): These routes are personalized and may display user-specific content. Blaze stores separate cache files for each user, identified by a uniqueblaze_idcookie. Changes to user-specific data invalidate the cache for that user only. - Public Routes (
blaze:public): These routes serve static content to all users. Blaze generates a single cache file for each public route, optimizing performance by serving pre-rendered HTML files.
- Private Routes (
4. Config the model for invalidating and refreshing the cache
- Model Integration:
- Add the
Blazetrait to your models to enable dynamic content generation. - Define which routes should be invalid and whether they are public or private in the
$blazeproperty of your models.
- Add the
-
Cache Invalidation:
- Blaze observes model changes and invalidates cache files associated with affected routes, ensuring content remains up-to-date.
Examples
- Below is an example of how you can integrate Blaze into your Laravel models for dynamic-static fusion:
Define
blaze_refresh = true, which will automatically update the cache by calling related routes regarding the $blaze array, note that enabling this feature may affect response time.
5. Nginx Config
- Add below map inside http {}
`
After that change / location to:
TODO
- [] Artisan command for cache public and private routes for add users.
- [] Minify static file.
All versions of blaze with dependencies
illuminate/support Version ^8.0|^9.0|^10.0
guzzlehttp/guzzle Version ^7.0