Laravel 8/7/6 Clear Route,Config,View Cache Tutorial

Laravel 8/7/6 Clear Route,Config,View Cache Tutorial

Laravel 8,7,6,5 clear all types of cache (route,config,view and app) command. In this laravel tutorial, you will learn two ways of how to clear all types of cache (route,config,view and app) from laravel 8,7,6,5 apps using command line and laravel artisan command.

For example, When your app is product mode or live mode; you need to create cache in laravel apps for better completion. But if your apps are in development mode then what want to do is not get cured due to the cache. At this time need to clear all types of cache.

How to Clear Cache in Laravel 8/7/6/5?

  • Using Command Line or Command Prompt
  • Using Artisan Commands

Solution 1 :- Laravel Cache Clear using Commands Line

  • 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

Solution 2:- 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

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL 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 *