Laravel deletes cache files manually. In this tutorial, you will learn how to delete cache files manually in Laravel apps with and without using artisan commands.
There are 3 methods available to clear the cache in Laravel app; you can delete or clear cache using the command line, manually and programmatically.
How to Clear Cache in Laravel Apps with and without using Artisan Command
Here are three methods to delete or clear cache from laravel application using artisan command, manually and programmatically:
Solution 1 – Laravel Clear route, app, config, and view cache using Artisan Command
Here are some commands to delete or clear all types of cache such as route, app, config, view cache in Laravel projects:
php artisan route:cache php artisan cache:clear php artisan config:cache php artisan view:clear php artisan optimize
Solution 2 – Laravel Clear Cache Without Artisan Command
If you do not access ssh on the shared hosting server, we can also clear the cache by typing the code in the root file. Go to your web.php file and add the following code to clear your application’s cache:
//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';
});
Solution 3 – Laravel Delete Cache Files Manually
If the cache is not cleared yet. Then go to the 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