How to clear cache using artisan in Laravel?

An application’s primary cache stores everything that is manually cached in the application. There are multiple ways to clear an application’s cache. We have learnt on how to clear cache in a Controller in Laravel. Let us now learn an even more simpler way, on how to clear cache using Laravel artisan commands.

We will look into a few commands that will clear various types of caches. For example config, route, view, and application cache of a Laravel application.

So open you terminal or command line, and cd into your Laravel project’s directory to use the clear cache artisan commands.

Clear Cache commands using artisan


To clear the entire application’s cache, you may use the command below.

php artisan cache:clear


To clear cache for your applications routes, use the following command as shown below.

php artisan route:clear


After changing the application’s configuration files or editing only the config directory files, you may need to clear only the configuration cache. Use the following command for it.

php artisan config:clear

View Blade

To clear cache for the view blade files of your Laravel project which are basically called the compiled view files, you may run the following artisan command.

php artisan view:clear

All cache

You can also clear all caches using a single command. Simply merge all single artisan commands using & operator as shown below.

/**[SAFE] Clears all cache with 1 line!**/ 
php artisan route:clear &&  
php artisan view:clear && 
php artisan config:clear &&
php artisan cache:clear && 
php artisan clear-compiled

You can also use the single smaller command as shown below to clear all cache.

php artisan optimize:clear

Leave a Comment