How to Clear Laravel Cache

In this tutorial, we will learn how to clear the different cache's stored by your Laravel app so that the changes you made are reflected.


Before we do this, open your terminal and cd to the root of your app (where the artisan file is located) as the following commands should be run from that location.


cd /path/to/site


Clear View Cache

The following command will clear all compiled views:


php artisan view:clear
Compiled views cleared!


Clear Route Cache

The following command will clear all route cache's:


php artisan route:clear
Route cache cleared!


Clear Config Cache

This command will clear the cache for all files located in the /config directory:


php artisan config:clear
Configuration cache cleared!


Clear all Cache's

To clear all the cache in your Laravel app, use the following:


php artisan cache:clear
Application cache cleared!


Caution – If you have a search index generated by TNTsearch or other similar software, this could get deleted too, so you may want to back those files up before running cache:clear.


Generate a New Laravel Cache

To generate a new cache for, views, config files and routes, use the optimize command like this:


php artisan optimize


Clear Laravel Cache from a Browser

If you can't SSH into your server, you can create a route that will clear the application cache when you access it from the browser.


Route::get('remove-cache', function() {
  return 'Application cache cleared!';