How to Clear cache in Laravel?

2024-04-26 04:32:16 Pankaj Dubey Laravel

Step to clear cache in Laravel

Clear database cache

In Laravel php artisan cache:clear command is used to clear cache.

It will remove all the cache associated with the connection to the database.

Usage:

php artisan cache:clear

Further, on shared hosting, you can use below code in your routes/web.php file to remove your database cache.

Laravel Clear Cache on Shared Hosting Server

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

Clear config cache

To clear config cache of your Laravel application run below command on terminal.

php artisan config:cache

Clear route cache

To clear route cache of your Laravel application run below command on terminal.

This post is submitted by one of our members. You may submit a new post here.

Related Tricks