Download the PHP package geniussystems-np/cache-middleware without Composer
On this page you can find all versions of the php package geniussystems-np/cache-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download geniussystems-np/cache-middleware
More information about geniussystems-np/cache-middleware
Files in geniussystems-np/cache-middleware
Package cache-middleware
Short Description Cache Middleware for Resources
License MIT
Informations about the package cache-middleware
Cache Middleware for Laravel/Lumen
We use two middleware for cache, one for serving response from cache and another for generating cache.
- ServeCachedResponse
- The only job will be serve the response from cache if available
- This middleware should be below the Authentication in the Middleware stack
- CacheReponse
- This middleware should analyze the response for it’s cacheability by checking the cache headers
- If the response is cacheable, it should cache the response in configured cache store(Redis)
- Currently, We are using only
cache-control
directive to cache the response
The package uses Laravel Cache
to store and serve response. Any response having cache-control
directive with max-age
will be cached for duration defined in max-age parameter.
Installing the package using composer
Once the package is installed, enable the Middleware in app/Http/Kernel.php
and add to your required middleware group.
ServeCacheResponse
should be after authentication middleware since it doesn’t pass the request to other middleware in the stack if there’s a response. Above code asumes you’re enabling cache-middleware
for all the routes. For specific routes, you need to added the middleware to it’s respective group and enable middleware in route.