Laravel Clear Cache, View, Routes and Config
Sometimes after route, creating view page or after installing new package, some features don’t work properly. Caching is responsible for these types of issues. Let’s have a look how to clear cache, view, routes and config.
Table of Contents
Using CLI
Just run these commands on CLI. Clear Cache:
php artisan cache:clearClear View:
php artisan view:clearClear Routes:
php artisan route:cacheClear Config:
php artisan config:cacheClear Session Files:
rm -f storage/framework/sessions/*Reoptimized Class:
php artisan optimizeUsing Artisan Command
Open routes/web.php and paste these lines:
// clear application cache
Route::get('/clear-cache', function() {
$exitCode = Artisan::call('cache:clear');
return 'Application cache cleared';
});
// 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 view cache
Route::get('/view-clear', function() {
$exitCode = Artisan::call('view:clear');
return 'View cache cleared';
});On shared hosting, you can clear eveything using this way.
The tutorial is over. Thanks for reading. ?Md Obydullah
Software Engineer | Ethical Hacker & Cybersecurity...
Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.