When we deploy laravel application on production, performace of an application becomes highest priority. Real users are going to use application and site may loose interest if it takes time to respond to users’ requests.
Laravel offers many optimization methods for cache optimization, query optimization, server tweaking etc. But in this blog, I will outline available methods in Laravel itself for better performance.
Disable Unused Service
Many times it happens that we don’t require to load all services when Laravel bootstraps. We can simply disable services which are not in use from config/app.php. We recommend to test full site to make sure everything works even after disabling un-used services.
Artisan Command to improve performance.
We all know Laravel comes with powerfull command line tool called “artisan”. We can use available artisan command to boost site’s performance.
php artisan config:cache php artisan route:cache php artisan optimize --force
This is useful when site consists lots of routes, configuration. This commands will just create a plain array from available configurations. This will be faster because Laravel does not require to load real objects after running above commands.
Please make sure to run above commands again as Laravel will be loading all content from cache and it will not find changes until we ru-run these commands again!