Package Data | |
---|---|
Maintainer Username: | denismitr |
Maintainer Contact: | denis.mitr@gmail.com (Denis Mitrofanov) |
Package Create Date: | 2017-05-28 |
Package Last Update: | 2020-02-15 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-20 03:01:25 |
Package Statistics | |
---|---|
Total Downloads: | 266 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 8 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 1 |
This a middleware specifically for the Laravel framework and RESTful APIs build with it. It hashaes the response content and adds it to ETag header of HTTP response. Then it listenes to If-Match and If-None-Match headers of the requests that expect to receive json in response in order to see if a new content needs to be delivered or just 304 Not Modified response is sufficient.
Denis Mitrofanov
Use composer to install the package:
composer require denismitr/etag
Include in your app/Http/Kernel.php
to the appropriate section
(all requests if all your routes are API or named middleware + API middleware group to make it work for every api route
or just named middleware):
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
...
\Denismitr\ETags\ETagMiddleware::class
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
...
'etag' => \Denismitr\ETags\ETagMiddleware::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
...
],
'api' => [
...
'etag'
],
];