loading...

Clear Cache in Laravel 7/6/5

pakainfocom profile image pakainfo ・2 min read

Many times you face an issue that any changes to the Laravel application are not reflecting on web interfaces. This occurred due to the application is being served by the cache. This tutorial will help you to clear the cache in the Laravel application.

Clear Cache in Laravel (Terminal)

Log in to the system running your Laravel application and open a terminal. Then navigate to your Laravel application code. Here you can issue the commands to clear cache as followings:

Clear Application Cache

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

php artisan cache:clear

Clear Route Cache

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

php artisan route:clear

Clear Configuration Cache

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

php artisan config:clear

Clear Compiled Views Cache

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

Clear Cache in Laravel (Browser)

Most of the shared hosting providers don’t provide SSH access to the systems. In that case, you can clear the Laravel cache by calling the URL in the browser. You can simply place the below code in your routes/web.php file of the Laravel application. Then access this URL in the browser to clear the cache of the Laravel application.

Route::get('/clear-cache', function() {
    Artisan::call('cache:clear');
    return "Cache is cleared";
});

Route::get('/clear-cache', function() {
    Artisan::call('cache:clear');
    return "Cache is cleared";
});

Posted on by:

pakainfocom profile

pakainfo

@pakainfocom

My name is Angular King. I'm a full-stack developer, entrepreneur and owner of Pakainfo. I live in India and I love to write

Discussion

pic
Editor guide