Home Linux How to Clear Cache in Laravel

How to Clear Cache in Laravel

How can I clear the cache in Laravel 5/6/7?

Sometimes changes done on the Laravel project not reflecting on the browser. In that case, need to clear the cache to reflect new changes done. In this tutorial, you will learn how to clear the cache on laravel application.

Clear Cache using Terminal

Open the terminal and go to the Laravel application path. Run the following commands to clear the cache.

1. Application Cache Clear

Run the below command to clear the application cache.

php artisan cache:clear

2. Route Cache Clear

To clear route-cache execute the below command.

 php artisan route:clear

3. Config Cache Clear

Run the following command to clear config cache.

php artisan config:clear

Clear Cache on Shared Hosting

Shared hosting does not provide ssh access to the server. In that case, we need to add the following code into the routes/web.php file in the Laravel application. Access this URL in the browser to clear the cache in shared hosting.

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

READ MORE: Docker Commands with Examples

That’s it.


Please enter your comment!
Please enter your name here