Navigate back to the homepage

Laravel Clear cache, config, view and Routes

February 6th, 2021 · 2 min read

Hello Friends 👋,

Welcome To Infinitbility! ❤️

Sometimes we faced Caching issues related to cache, config, view, and route. no effect of Hard and soft refresh. below you will learn how to clear cache from Laravel for all modules.

Caching configuration helps with combining all of the configuration options for your application into a single file which will be loaded quickly by the framework.

Clear Cache

Using Laravel’s Cache is a great way to speed up frequently accessed data in your application. While developing your application involving cache, it is important to know how to flush all cache correctly to test if your cache is working properly.

To clear your application cache, you may run the following Artisan command:

1$ php artisan cache:clear
2Application cache cleared!

This will clear all the cache data in storage which are typically stored in /storage/framework/cache/data/. The effect is similar to calling the Cache::flush(); Facade method via code.

Clear Config

However, if you notice changes to the configuration values in .env file is not reflecting on your application, you may want to consider clearing the configuration cache with the following command:

1$ php artisan config:clear
2Configuration cache cleared!

If you want to quickly reset your configuration cache after clearing them, you may instead run the following command:

1$ php artisan config:cache
2Configuration cache cleared!
3Configuration cached successfully!

Caching your configuration will also help clear the current configuration cache. So it helps save your time without having to run both commands.

Clear Routes

Caching your routes will drastically decrease the amount of time it takes to register all of your application’s routes. When you add a new route, you will have to clear your route cache for the new route to take effect.

The following command will clear all route cache in your application:

1$ php artisan route:clear
2Route cache cleared!

To cache your routes again, simply run the following command:

1$ php artisan route:cache
2Route cache cleared!
3Routes cached successfully!

Again, running the above command alone is enough to clear your previous route cache and rebuild a new one.

Clear View

Views are cached into compiled views to increase performance when a request is made. By default, Laravel will determine if the uncompiled view has been modified more recently than the compiled view, before deciding if it should recompile the view.

However, if for some reason your views are not reflecting recent changes, you may run the following command to clear all compiled views cache:

1$ php artisan view:clear
2Compiled views cleared!

In addition, Laravel also provides an Artisan command to precompile all of the views utilized by your application. Similarly, the command also clears the view cache before recompiling a new set of views:

1$ php artisan view:cache
2Compiled views cleared!
3Blade templates cached successfully!

Clearing All Cache

Laravel provides a handy Artisan command that helps clear ALL the above caches that we have covered above. It is a convenient way to reset all cache in your application, without having to run multiple commands introduced before.

To clear all Laravel’s cache, just run the following command:

1$ php artisan optimize:clear
2Compiled views cleared!
3Application cache cleared!
4Route cache cleared!
5Configuration cache cleared!
6Compiled services and packages files removed!
7Caches cleared successfully!

As you can read from the terminal feedback, all cache types that existed in your Laravel application will be cleared entirely, except Events cache.

Thanks for reading…

More tutorial form Laravel

  1. Yajra issue after install in laravel
  2. Laravel call function from another class
  3. laravel pagination with customization
  4. How to solve page expired error in laravel for webhooks, ajax, and form
  5. Laravel Model
  6. Laravel Clear cache, config, view and Routes
  7. how to force Laravel to use https in URL and assets

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide



More articles from Infinitbility

React Native commands you need almost every day

React Native commands you need almost every day bookmark on your machine.

February 4th, 2021 · 1 min read

How to deploy nodejs application subdirectory level in apache ubuntu

Deploy your nodejs application to subdirectory url level in apache server.

February 1st, 2021 · 1 min read
© 2020–2022 Infinitbility
Link to $ to $ to $ to $ to $ to $mailto:[email protected]