laravel-etag-middleware | Laravel middleware for adding ETags | HTTP library
kandi X-RAY | laravel-etag-middleware Summary
kandi X-RAY | laravel-etag-middleware Summary
A Laravel middleware for adding ETags to HTTP requests to improve response times
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Handle the incoming request
laravel-etag-middleware Key Features
laravel-etag-middleware Examples and Code Snippets
composer require matthewbdaly/laravel-etag-middleware
\Matthewbdaly\ETagMiddleware\ETag::class
Community Discussions
Trending Discussions on laravel-etag-middleware
QUESTION
I have a big JSON file accessible from myapp.org/api/something
which is updated everyday at midnight. From this route I simply fetch some records from my database.
But as I know the records in that datbaase will only change once a day, I would like to tell my browser to use its cache to retrieve this resource.
So I would like to have:
- An expiration time of 12h from which the browser will simply use its cache
- Then an ETAG from which the browser will query the backend and perhaps get a 304 status code.
I am using the latest version of Laravel and I did not find any out-of-the-box information to manage resource cache.
How can I implement this with Laravel?
I have found this middleware but I am sure a feature such as cache and 304 status code should be available with a vanilla installation of Laravel, am I wrong?
...ANSWER
Answered 2019-Jun-23 at 08:58You could look into 3rd party libraries for caching. Spatie/laravel-responsecache seems a good option at first glance. Alternatively you could implement it yourself, but that feels like reinventing something which other people probably solved already.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install laravel-etag-middleware
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page