Clear caching in Laravel

We can clear cache using command line with Laravel artisan commands. Run following command in command line one by one.

php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan clear-compiled
php artisan config:cache

Now we can clear all cache on server without using command line

Route::get('/clear', function() {

   Artisan::call('cache:clear');
   Artisan::call('clear-compiled');
   Artisan::call('config:clear');
   Artisan::call('config:cache');
   Artisan::call('view:clear');

   return "Cleared!";

});

Leave a Reply

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

Follow by Email
LinkedIn
Share
Instagram