Laravel 9 Clear Cache with Artisan Command (CLI)

Last updated on: by Digamber
Today in this tutorial, we are going to learn how to clear route cache, laravel application cache, config cache, view cache and reoptimized class in a Laravel application using artisan command-line interface.

We will also learn how to remove cache in laravel without the need of artisan commands.

I’m pretty sure many of you may have found yourself gotten into the situation where you do not see changes in the view after making the changes in the app.

Laravel application serves the cached data so caching problem occurs due to the robust cache mechanism of Laravel.

But, if you are still facing this issue, then you do not have to worry further. Let me do the honour of introducing you some of the best artisan commands to remove the cache from your Laravel app via PHP artisan command line interface.

Artisan is the command-line interface included with Laravel. It provides a number of helpful commands that can assist you while you build your application.

Also see: Create PHP Laravel 6.8 CRUD App with MySQL Database

Clear Route Cache in Laravel

Laravel caching system also takes routes in consideration, to remove route cache in Laravel use the given below command:

php artisan route:cache

Clear Application Cache in Laravel

Run the following command to clear application cache:

php artisan cache:clear

Clear Config Cache in Laravel

Run the following command to clear config cache:

php artisan config:cache

Clear View Cache in Laravel

Run the following command to clean your view cache:

php artisan view:clear

Reoptimize Class

Run the below command to reoptimize the class loader:

php artisan optimize


We have completed this Laravel 6 tutorial, In this tutorial we learned how to use php artisan command to clear the cache from your Laravel application. We have answered the following questions in this article.

  • How to clear route cache using php artisan command?
  • How to easily clear cache in Laravel application?
  • How to clear config cache in PHP Laravel via artisan command?
  • How to clear Laravel view cache?
  • How to Reoptimized class in Laravel via artisan CLI?

Laravel clear cache without artisan

Its not possible with shared hosting servers to access SSH there relying on artisan commands to clear, remove or delete cache in Laravel. However, there is one more trick in my book, and that is incorporating THE Artisan::call() method within the routes/web.php file with given below methods.

As you can see, how much simple is that:

// Remove route cache
Route::get('/clear-route-cache', function() {
    $exitCode = Artisan::call('route:cache');
    return 'All routes cache has just been removed';
//Remove config cache
Route::get('/clear-config-cache', function() {
    $exitCode = Artisan::call('config:cache');
    return 'Config cache has just been removed';
// Remove application cache
Route::get('/clear-app-cache', function() {
    $exitCode = Artisan::call('cache:clear');
    return 'Application cache has just been removed';
// Remove view cache
Route::get('/clear-view-cache', function() {
    $exitCode = Artisan::call('view:clear');
    return 'View cache has jut been removed';

Its your turn to let me know what do you think about this laravel clear cache tutorial.

Go ahead and try your hands on both the methods to remove the cache in Laravel.


I am Digamber, a full-stack developer and fitness aficionado. I created this site to bestow my coding experience with newbie programmers. I love to write on JavaScript, ECMAScript, React, Angular, Vue, Laravel.