Several times we have faced an issue that we make any changes to the Laravel application are not reflecting on web interfaces. This issue has been occurred due to the application is being served by the cache.Below blog post tutorial will help you how to clear cache in the Laravel application.
Clear Cache in Laravel through Terminal
Firstly we should Log in to the system where our Laravel application is running and then open a terminal.
Then we have to navigate to the Laravel application code. Here we can issue the commands to clear cache from applications as followings:-
1. Clear Application Cache
We are going to run the following command to clear application cache of the Laravel application
$ php artisan cache:clear
2. Clear route cache
To clear route cache of our Laravel application we should execute the following command from the shell.
$ php artisan route:clear
3. Clear config cache
We can use config:clear to clear the config cache from the Laravel application.
$ php artisan config:clear
4. Clear compiled view files
Sometimes also we 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 from Browser in Laravel
We can simply place the following code in our routes/web.php file of Laravel application and access this URL in browser to clear the cache from Laravel application.
Route::get('/clear-cache', function() { Artisan::call('cache:clear'); return "Cache is cleared"; });