Laravel Clear Route, Config and View Cache Commands

Laravel Clear Route, Config and View Cache Commands

Laravel 8,7,6,5 clear cache command. In this laravel tutorial, you will learn two ways of how to clare different types of cache from laravel apps, as shown below:

  • how to clear cache routes
  • how to clear config cache
  • how to clear view cache

For example, When our app is product mode (live), need to make cache in laravel apps for better completion. But if our apps are in development mode then what want to do is not get cured due to the cache. At this time need to clear the cache.

And this tutorial will discuss two ways of clear all caches from laravel apps. You can see the following ways:

  • Command Line or Command Prompt
  • Artisan Commands

First Way:- Laravel Cache Clear Commands

You can see all laravel clear cache commands, as shown below:

  • Laravel Clear Route Cache
  • Laravel Clear App Cache
  • Laravel Clear Config Cache
  • Laravel Clear View Cache
  • Laravel Clear Cache using Reoptimized Class

Laravel Clear Route Cache

Use the below command and clear your routes cache :

php artisan route:cache

Laravel Clear App Cache

Use the below command and clear your application cache like session cache, cookies cache:

php artisan cache:clear

Laravel Clear Config Cache

Use the below command and clear your config cache :

php artisan config:cache

Laravel Clear View Cache

Use the below command and clear your view (blade) cache :

php artisan view:clear

Laravel Clear Cache using Reoptimized Class

php artisan optimize

Second Way:- Laravel Cache Clear using Artisan Command

If you do not access SSH on shared hosting servers, then we can also clear the cache by typing the code in route file. Go to your web.php file and put below code for clear cache of your application :

//Clear route cache:
Route::get('/route-cache', function() {
$exitCode = Artisan::call('route:cache');
return 'Routes cache cleared';

//Clear config cache:
Route::get('/config-cache', function() {
$exitCode = Artisan::call('config:cache');
return 'Config cache cleared';

// Clear application cache:
Route::get('/clear-cache', function() {
$exitCode = Artisan::call('cache:clear');
return 'Application cache cleared';

// Clear view cache:
Route::get('/view-clear', function() {
$exitCode = Artisan::call('view:clear');
return 'View cache cleared';

Recommended Laravel Posts

Recommended:-Laravel Try Catch


My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Vue JS, Angular JS, React Js, WordPress, and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *