Ways to Improve Laravel Performance

Tim
Tim
Feb 25, 2017 · 1 min read

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.

Written by

Tim

Developer | Blogger

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade