Laravel Tip - Cache The Entire Response And Make Your App Load Faster
HTML-код
- Опубликовано: 19 окт 2024
- In this video, we will use laravel middleware to cache the entire response and make our website much faster. Instead of caching some part of our application like MySQL queries, we will cache the entire response.
Social Media Links:
Let's be friends
/ aashish_dhamala
Follow On Facebook
/ laratipsofficial
Follow On Twitter
/ laratips1
Tech stack:
Laravel
PHP
MySQL
#laravel #php #laraveltip #laratips #mysql
Thanks for your help and great tutorial
You are most welcome
Cleared the concept Thanks
best video on cache i ever seen. Thank you :)
Great! How about the dynamic pages? like - insert, update, delete. I hope you got my point. where content are changing dynamically regularly.
You can make use of cache tags in that case.
Great Video!! Thanks for sharing!! Can we get to know what are the VS Code extensions are you using?
I am using these extensions for laravel:
Laravel Blade formatter
Laravel Blade Snippets
Laravel Extra Intellisense
Laravel goto view
Laravel-goto-controller
PHP Intelephense
PHP Namespace Resolver
@@Laratips Thank you so much!!
You are welcome
Great Video... Can we know which tool you use at the bottom of the browser to check number of queries.
It's laravel Debugbar package
Great video but you didnt tell us how to remove cache ? since the system is not reaching to the controller !!! For example after update I want to call clear cache method ..
The update is done on the admin section and you can easily call cache:clear command from the controller where you have updated the data. Then you will get fresh data on the front-end.
But lets say if you want to clear the cache for the specific page then you can make use of cache tags. You can check laravel docs for that.
Thanks for great videos. Please can you create video on multi auth in laravel 8 jetstream and two factor auth with laravel 7 .
Jetstream does not support multiauth. We can use laravel breeze.
Sure, i will make a video on the two factor auth in the future. Stay tuned.
No sir...jetstream can also support multiauth
Great, if you have an working example please share. It will be beneficial for us all.
Great video, Thank you!!
Can you tell me what tools you use in the browser?
Lol. I just noticed the comment today. The tool is called "laravel debugbar" 😅
Cache update if request will be changed?
What if when new data is saved and we need to renew the cache?
You can make use of cache tags. Just invalidate the tag when there is new data and it will load fresh page.
brother tyo console ko debugger ko name k ho?
github.com/barryvdh/laravel-debugbar
Debugbar
is it works for HTML ???
You don't need this for html.
@@Laratips actually i mean just for blade template in laravel, where i used pure html. Thanks to you it works, but how can i use cache tag for data change time from database???
@@AhsanHabib-vt2dq I am sorry, I couldn't understand what you mean to say. Could you make it a little bit clear plz?
@@Laratips i already used your process and it works but i cannot update the cache when i changed data in database. How i update cache with new html data when i will update database?
You can pass tag name from the middleware and then clear the cache based on the tag. You can check the laravel docs to know more about tags: laravel.com/docs/9.x/cache#cache-tags
Guys dont forget to delete the cache, when there was a change in the database.
Thanks for your input.
Yes absolutely. But I think we can and the database name and connection in the cache key as well so that we don't have to remember to clear the cache.
@@Laratips as per my knowledge database name and connection are fixed ! what do you mean exactly ?
Cache::remember?
Thanks for mentioning. Yes we can use this instead of checking for cache and then returning.
@@Laratips it's much more efficient I guess,