How to manually clean the Laravel cache
Learn how to manually clear Laravel's cache with an example to optimize your website's loading speed.
Cleaning Laravel Cache Manually
Caching is an effective way to improve the performance of any application. It can be used to store data in a faster and more efficient way than accessing it from a database or other sources. In Laravel, caching can be used to store data such as routes, views, and configuration. However, in order to keep the cache up to date, it is necessary to clean it periodically.
Fortunately, Laravel provides several ways to clean the cache manually. In this article, we will explore how to clean the Laravel cache manually using the Artisan command line utility.
Using Artisan to Clean the Laravel Cache
The Artisan command line utility provides several commands for cleaning the Laravel cache. To clean the entire cache, you can use the php artisan cache:clear
command. This command will delete all the entries in the cache.
If you want to clean only a specific type of cache, you can use the php artisan cache:clear <cache-type>
command. For example, to clear the route cache, you can use the php artisan cache:clear routes
command. Similarly, you can use the php artisan cache:clear views
command to clear the view cache.
If you want to clear the configuration cache, you can use the php artisan config:clear
command. This command will clear the configuration cache, which stores the configuration files in the application. This command is especially useful when you have made changes to the configuration files and want to apply them without restarting the application.