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

358

3 years ago

0 comments

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

Alaz

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

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this