How to Clear Laravel Cache Application, route, config and view

clear laravel cache
clear laravel cache

Laravel provides an expressive, unified API for various caching backends. The cache configuration is located at config/cache.php. In this file you may specify which cache driver you would like to be used by default throughout your application. Laravel supports popular caching backends like Memcached and Redis out of the box.

Clear laravel cache for application, route, config and view cache by PHP atrisan commaned and by Browser. on browser option need to add code in your routes/web.php

1. Clear Application Cache

Run the following command for clear Laravel cache of the application.

php artisan cache:clear

2. Clear route cache

To clear route cache of your application execute the following command from the shell.

php artisan route:cache  

3. Clear config cache

You can use config:cache to clear the config cache of the application.

php artisan config:cache  

4. Clear compiled view files

Also, you 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 

5. clear cache by flush method:

Flushing the cache does not respect the cache prefix and will remove all entries from the cache. Consider this carefully when clearing a cache which is shared by other applications.


Clear Cache in (Browser)

Most of the shared hosting providers don’t provide SSH access to the systems. In that case, you can clear cache by calling URL in the browser. You can simply place the below code in your routes/web.php file of Laravel application. Then access this URL in the browser to clear the cache of the laravel 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';

know more from

Leave a Reply

Your email address will not be published.

%d bloggers like this: