Sometimes you may face an issue that the changes to the Laravel Project may not update on the web. This occures when the application is served by the cache. In this tutorial, You’ll learn to Clear Application, Route, Config, Browser Cache in Laravel Project.
Go to your Laravel Project and open the Terminal. Here you can type the commands to clear cache as show below :
- Clear Route Cache
Type the following command to clear route cache of the Laravel application.
php artisan route:cache
Code language: CSS (css)
- Optimize Laravel Cache
Note : The Artisan optimize command is deprecated as of 5.5. With recent improvements to PHP itself including the OPcache, the optimize command no longer provides any benefit.
php artisan optimize
- Clear Application Cache
Type the following command to clear application cache of the Laravel application.
php artisan cache:clear
Code language: CSS (css)
- Clear Configuration Cache
Type the following command to clear configuration cache of the Laravel application.
php artisan config:cache
Code language: CSS (css)
- Clear View Cache
Type the following command to clear view cache of the Laravel application.
php artisan view:clear
Code language: CSS (css)
- Clear Browser Cache
You can clear the cache by defining the command inside the router.Then access this URL in the browser to clear the cache of Laravel project.
Route::get('/clear-cache', function() {
Artisan::call('cache:clear');
return "Cache is cleared";
});
Code language: PHP (php)
Hope this tutorial helped you! Feel free to drop your opinion at the comment section.