HomeLaravel

How to Clear Cache in Laravel 5

How to Clear Cache in Laravel 5
Like Tweet Pin it Share Share Email

While developing Laravel websites, Many times we are facing issues of Cache. While I developing the Laravel website, one time everything is working fine on the localhost when I uploaded code on the server and tested many times it was not working fine.

While searching on Laravel Cache, I read the document and used the below php artisan commands. This tutorial will help you to clear the cache in the Laravel application.

Method 1: Using Terminals

Open the terminal and go to the application folder and hit the below php artisan commands.

Clear Application Cache

Run the below command to clear the application cache of the Laravel application.

php artisan cache:clear

Clear Route Cache

Run the below command to clear the route cache of the Laravel application.

php artisan route:cache

Clear Config Cache

Run the below command to clear the Config cache of the Laravel application.

php artisan config:clear 

Clear view files Cache

Run the below command to clear view file cache of the Laravel application.

php artisan view:clear

Method 2: Using Routes in Browser

Sometimes we don’t have access to the SSH because of the shared hosting. That time we need to clear cache using browser.

Copy the below code and place it into the routes/web.phpat the top or at the bottom. Then access below URLs in the browser to clear the cache of Laravel application.

//Clear route cache:
 Route::get('/route-cache', function() {
     Artisan::call('route:cache');
     return 'Routes cache cleared';
 });

 //Clear config cache:
 Route::get('/config-cache', function() {
     Artisan::call('config:cache');
     return 'Config cache cleared';
 }); 

// Clear application cache:
 Route::get('/clear-cache', function() {
     Artisan::call('cache:clear');
     return 'Application cache cleared';
 });

 // Clear view cache:
 Route::get('/view-clear', function() {
     Artisan::call('view:clear');
     return 'View cache cleared';
 });

 

Thanks for reading our article. What Next?

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

4 + twenty =