Application 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.
Clearing Application Cache
To clear your application cache, you may run the following Artisan command:
$ php artisan cache:clear
Application 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.
❗️ This command will NOT clear any config, route, or view cache, which are stored in /bootstrap/cache/ directory.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:
$ php artisan optimize:clear
Compiled views cleared!
Application cache cleared!
Route cache cleared!
Configuration cache cleared!
Compiled services and packages files removed!
Caches 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.
❗️ TheCompiled services and packages files removed!can be run individually via$ php artisan clear-compiledcommand. It is used to remove the compiled class file in the framework.
More information about Clearing Application Cache : https://itmaster-soft.com/en/laravel-app-development-services