Jamie's Blog

Lessons from a life of startups, coding, countryside, and kids

Speeding up Rails development

A brand new Rails app is a joy to work on but over the past few weeks I’ve noticed the app getting slower in development as, in hindsight, I added more and more stylesheets and javascripts. The culprit, I quickly realised, was the asset pipeline. On each page refresh it was reloading all the assets, compiling the .less and coffeescript files etc. And since I was using nginx with a 30sec timeout, the page refreshes would often fail and the workers would hit 100% CPU usgae. I got around this by pre-compiling the assets (as you’d do in production) but this week I got majorly bitten by these old pre-compiled assets taking priority over the master assets. So, I was back to 30sec page requests in development. Not fun.

I did a little googling and the rails-dev-tweaks gem came up. In short, it’s a lifesaver. It only reloads assets that have changed and it’s so far been spot-on about refreshing new files but still serving the pages in fractions of a second. I’m sure there are some gotchas but it’s a huge productivity boost

In short: using Rails 3? Install rails-dev-tweaks