Laravel delete cache files manually. In this laravel tutorial, you will learn how to delete cache files manually in laravel apps.
As you know. There are 2 methods available to clear the cache in Laravel app. The cache of the app can be cleared using the command line. And in the other way the artisan can be executed by creating a route.
So in this tutorial, you will see another method by which you can delete the cache files to clear the cache in Laravel app.
How to Clear Cache in Laravel Apps
In this tutorial, you will know 3 ways by which you can clear the cache of Laravel app. which are given below:
- Solution 1 – Laravel Clear route, app, config ,view cache using Command Line
- Solution 2 – Laravel Cache Clear using without Command
- Solution 3 – Laravel Delete Cache Files Manually
Solution 1 – Laravel Clear route, app, config ,view cache using Command Line
Let’s use the different types of commands to delete or clear route, app, config ,view cache in laravel 10, 9,8,7,6 apps:
php artisan route:cache php artisan cache:clear php artisan config:cache php artisan view:clear 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';
});
Solution 3 – Laravel Delete Cache Files Manually
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