Ways to Improve Laravel Performance

Tim
1 min readFeb 25, 2017

--

Over the past few months my Weather Extension has grown to over 118,000+ users. Weather uses Laravel primarily as an api and VueJs to render the html. Speed is very important. Currently Weather is hosted on a $40 a month Digital Ocean server. Since Weather is free, I’ve tried my best to keep cost low. Here are a few changes I’ve made to improve the performance of my Laravel app.

  • Use caching whenever possible. I cache user data, settings and locations. This limits the amount of sql queries. Just make sure you invalidate the cache when the data changes.
  • Make sure you have good indexes for your database
  • Cache your configs, routes and views. Add these commands to your Forge deploy script. Read more about config caching here
  • php artisan config:clear
  • php artisan route:cache
  • php artisan view:clear
  • Install/Setup PHP OPcache. OPcache will cache your php code so it doesn’t have to recompile. Check out this guide.

I would love to hear what you have done to improve speed and performance for your Laravel app. Please leave a comment below.

Originally published at Tim Leland.

--

--