In this article you will learn how to clear cache of you application in PHP Laravel
In Laravel, you can use the Artisan
command-line interface (CLI) to clear the cache. The Artisan command for clearing the cache is cache:clear
.
Here is an example of using the cache:clear
command to clear the application cache:
php artisan cache:clear
This command will clear the application cache, which includes the configuration cache, the route cache, and the view cache.
You can also use config:cache
and route:cache
command to clear the config and route cache separately:
php artisan config:clear
php artisan route:clear
In addition, you can also use view:clear
command to clear the view cache:
php artisan view:clear
It's important to note that before running these commands make sure you are in the root directory of your laravel application.
It's also a good practice to clear the cache after making changes to the application's configuration or routes, as the cache can sometimes cause issues with the application's behavior.
php artisan optimize all in one package
In Laravel, the php artisan optimize
command is used to optimize the framework for better performance. This command performs several actions that can help improve the performance of a Laravel application, such as caching the configuration, routes, and compiled views, and concatenating all the application's service providers.
Here is an example of using the php artisan optimize
command:
php artisan optimize
When you run this command, it will run several sub-commands, such as:
By caching these files, the framework doesn't need to load them every time a request is made, which can result in a significant performance improvement.
It's important to note that the php artisan optimize
command should be run after any changes are made to the application's configuration or routes, as the cached files may cause issues with the application's behavior. Also, this command should only be used on production environments, as it disables the debug mode and the error reporting.
Also, you can use php artisan config:clear, php artisan route:clear, php artisan view:clear
to clear the config, route and view cache separately.