Laravel 10, 9, 8, 7 Clear Route,Config,View Cache Example

Laravel clear route,config,view and app cache with and without using command. In this laravel tutorial, you will learn how to clear route,config,view and app from laravel 10, 9, 8,7,6,5 apps using artisan command and without 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 10, 9,8,7,6?

Use the following two ways to clear route, app, config ,view cache from our laravel 10, 9, 8, 7, 6, 5 apps:

  • Solution 1 – Laravel Clear route, app, config ,view cache using Command Line
  • Solution 2 – Laravel Cache Clear using without Command

Solution 1 – Laravel Clear route, app, config ,view cache using Command Line

Let’s use the different types of commands to delete/clear route, app, config ,view cache in laravel 10, 9,8,7,6:

  • 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 without 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';
});

If the cache is not cleared yet. Then go to bootstrap/cache directory. And delete all files and sub directories inside the bootstrap/cache directory.

Or, you can execute the following on the terminal instead of manually deleting the file:

cd bootstrap/cache/
rm -rf *.php

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 *