Download the PHP package stounhandj/laravel-cache-route without Composer
On this page you can find all versions of the php package stounhandj/laravel-cache-route. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stounhandj/laravel-cache-route
More information about stounhandj/laravel-cache-route
Files in stounhandj/laravel-cache-route
Package laravel-cache-route
Short Description Cache (HTML) output of entire route to speedup your Laravel application
License MIT
Informations about the package laravel-cache-route
Cache contents of entire route in Laravel
This is the Laravel 7.0+ / PHP 7.2+ package, which provides the ability to cache routes for the allotted time.
Installation
Or
Usage
Add middleware to the file kernel.php:
Now, use the middleware to cache the HTML output of an entire page from your route like so:
-
In your route:
You may also use route groups. Please look up Laravel documentation on Middleware to learn more here
Configuration Options
You can configure the TTL (Time-To-Live) to cast per second:
-
In your route:
- Environment (On all routes at once):
Thoughts
Be VERY cautions when using a whole page cache such as this. Remember contents of the cache are visible to ALL your users.
- For, "mostly static" content, go for it!
- For, "mostly dynamic" content or heavily user-customized content, AVOID this strategy. User specific information is gathered server side. So, you essentially WANT to hit the server.
Good rule of thumb: If two different users see different pages on hitting the same URL, DO NOT cache the output using this strategy. An alternative may be to cache database queries.
All versions of laravel-cache-route with dependencies
laravel/framework Version ^7.0|^8.0|^9.0
illuminate/contracts Version ^6.9|^7.0|^8.0|^9.0
illuminate/support Version >=6.0
illuminate/http Version >=6.0