Home / Snippets / How to Cache Route and Cache Config in Laravel 8
How to Cache Route and Cache Config in Laravel 8 cover

How to Cache Route and Cache Config in Laravel 8


2 years ago


In Laravel, each time a request is made will pass through the lifecycle of the application up till it returns a response. During each of those requests, the routes and configs are read to get the right data and value.

To speed this up you can cache both route and config by running the command below.

Cache the Route

To cache the route, you can run the "route:cache" artisan command. This command will cache all the URLs defined on "/routes" directory.
php artisan route:cache

Cache the Config

To cache the config you can use "config:cache" artisan command and this command will cache the configurations that's defined from "/config" directory.
php artisan config:cache
Do note that any new configuration you have included won't take effect until you "clear" the cache. To clear the cache you can run:
php artisan route:clear
And for the config run it like below.
php artisan config:clear

Other Reads

notion avatar

Ahmad Aziz

Week-end developer currently experimenting with web, mobile, and all things programming.






Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Post Tutorials

Learn trending tutorials for ReactJs, React Native, VueJS, NextJs, Laravel, Tailwind CSS, and Flutter development.
View Tutorials

Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your web projects
View Components

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this