In this tutorial, We will discuss to you how to clear cache using artisan command in Laravel 8(Laravel 8 Clear Cache Using Artisan Command). sometimes we face an issue that any changes to our laravel application are not reflecting on the web interface. At that time we have a need to clear the cache for our laravel application.
There are many types of cache available in laravel like route cache, view cache, application cache, and config cache. so we can easily clear cache using the artisan command. let’s see the following clear cache.
Clear Laravel Application Cache
Here below command help to Clear Laravel Application Cache.
php artisan cache:clear
If you want to Clear Laravel Application Cache without php artisan command so you can below code using to Clear Laravel Application Cache.
Route::get('/clear-application-cache', function() { Artisan::call('cache:clear'); return 'Application cache cleared'; });
Clear Route Cache
Here below command help to Clear Route Cache.
php artisan route:cache
If you want to Clear Route Cache without php artisan command so you can below code using to Clear Route Cache.
Route::get('/clear-route-cache', function() { Artisan::call('route:cache'); return 'Routes cache cleared'; });
Clear Config Cache
Here below command help to Clear Config Cache.
php artisan config:cache
If you want to Clear Config Cache without php artisan command so you can below code using to Clear Config Cache.
Route::get('/clear-config-cache', function() { Artisan::call('config:clear'); return 'Config cache cleared'; });
Clear View Cache
Here below command help to Clear View Cache.
php artisan view:cache
If you want to Clear View Cache without php artisan command so you can below code using to Clear View Cache.
Route::get('/clear-view-cache', function() { Artisan::call('view:clear'); return 'View cache cleared'; });