How to delete or clear caching in Laravel (Clear Cache in Laravel (Terminal)) Print

  • 0

Log in to the system running your Laravel application and open a terminal. Then navigate to your Laravel application code. Here you can issue the commands to clear the cache as follows:

Clear Application Cache
Run the following command to clear the application cache of the Laravel application.

php artisan cache:clear

Clear Route Cache

To clear the route cache of your Laravel application execute the following command from the shell.

php artisan route:clear

Clear Configuration Cache
You can use config:clear to clear the config cache of the Laravel application.

php artisan config:clear

Clear Compiled Views Cache

Also, you may need to clear compiled view files of your Laravel application. To clear compiled view files run the following command from the terminal.

php artisan view:clear

Clear Cache in Laravel (Browser)

Most of the shared hosting providers don’t provide SSH access to the systems. In that case, you can clear the Laravel cache by calling the URL in the browser. You can simply place the below code in your routes/web.php file of the Laravel application. Then access this URL in the browser to clear the cache of the Laravel application.


Route::get('/clear-cache', function() {
Artisan::call('cache:clear');
return "Cache is cleared";
});


Was this answer helpful?

« Back