Posts Learn Snippets Categories Tags About

How to Clear Cache in Laravel

Learn how to clear cache in Laravel 6/7/8 and get your route, views, configuration cleaned

Created on Jul 21, 2021


In this snippet, you'll learn how to clear Laravel Application Cache, Laravel Config Cache, Laravel Route Cache, and Laravel Compiled Views Cache.

Clear Application Cache
To clear your Laravel application cache you can run the command below.
php artisan cache:clear

Clear Configuration Cache
To clean your environment (.env) configuration cache, run the command below.
php artisan config:clear

Clear Route Cache
To clear all of your Laravel route cache you can run the command below.
php artisan route:clear

Clear Compiled Views Cache
To clear the compiled views cache that Laravel has rendered, you can run the command below.
php artisan view:clear

Extra: Clear Cache from Browser
Sometimes you might have no access (SSH) to the terminal in production. In this case, you can define a new web route to clear the cache.
# /routes/web.php


Route::get('/clear-all-cache', function () {

  return 'The application cache has been cleared';

Created by

PostSrc poster


Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.