Laravel 8 Clear Cache of Route, View & Config

Reading Time: 4 minutes

When we do application development in Laravel, as a developer sometimes you have observed that site saves cache of route, view and routes. Due to this, sometime changes doesn’t reflect to pages, sometimes we get the old data on the output screen.

To overcome this issue we are going to see the concept of Laravel 8 Clear cache of route, view & config. These commands are not actually dependent of laravel version. It runs to all application of any version of laravel. These are global artisan commands of laravel.

Inside this tutorial we will see Clear cache of route, view and configuration of laravel application. Laravel provides the list of artisan command which helps to remove complete caches.

Let’s get started.

Laravel Artisan Command Panel

When we open laravel project into terminal and type the command

$ php artisan and press enter, we will get the full list of artisan commands. Have a look we have marked few cache related console commands.

Cache Related Commands

Open laravel application into console and hit these commands according to the need.

Clear Cache

$ php artisan cache:clear

Clear Route Cache

$ php artisan route:clear

Clear View Cache

$ php artisan view:clear

Clear Config Cache

$ php artisan config:cache

These all are command by the help of which we can clear cache of View, Routes & Config. Alternative way to clear caches is by making a route and execute the command. This will do the same function.

Clear Cache by Route – Without Command

Inside this we will create a route into /routes/web.php file. That route when we call, then it clears the cache of the application.

Route::get('clear-all-cache', function() {
    dd("Successfully, you have cleared all cache of application.");

Behind the scene, it is going to execute the command as

$ php artisan cache:clear

Same we can do for route [ Artisan::call(‘route:clear’); ], views [ Artisan::call(‘view:clear’); ] & config [ Artisan::call(‘config:clear’); ]

Application Testing

Run this command into project terminal to start development server,

php artisan serve

URL- http://localhost:8000/clear-all-cache

We hope this article helped you to learn about Laravel 8 Clear Cache of Route, View & Config Tutorial in a very detailed way.

Online Web Tutor invites you to try Skillshike! Learn CakePHP, Laravel, CodeIgniter, Node Js, MySQL, Authentication, RESTful Web Services, etc into a depth level. Master the Coding Skills to Become an Expert in PHP Web Development. So, Search your favourite course and enroll now.

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.

Sanjay KumarHello friends, I am Sanjay Kumar a Web Developer by profession. Additionally I'm also a Blogger, Youtuber by Passion. I founded Online Web Tutor and Skillshike platforms. By using these platforms I am sharing the valuable knowledge of Programming, Tips and Tricks, Programming Standards and more what I have with you all. Read more