RailsCasts Pro episodes are now free!

Learn more or hide this

John McCaffrey's Profile

GitHub User: jmccaffrey

Site: http://railsperformance.blogspot.com

Comments by John McCaffrey

Avatar

Great post Ryan!

While this is very exciting, I can see that people are unsure just when and where this technique should be applied, and if it should now take precedence over other performance best practices.

My advice would be to make sure you are doing all of the 'other' performance tuning things first, as they are generally easier to implement, easier to understand, and more battle tested. (gzip, combine/minify, leverage browser cache, optimize images, defer loading js, use ajax where it makes sense ... etc)

I would focus on all the stuff recommended by yslow, page speed, dynatrace, et al, first, as that stuff can be implemented right now, on any server, regardless of browser/mobile, proxy, whatever.

So when DOES it make sense to use streaming?
When you can give the user something to look at quickly and defer expensive processing for a bit later. Maybe you have a certain amount of 'chrome' at the top of your site, and you want to get it in front of your user quickly so they can orient themselves to the task at hand (google, yahoo, amazon, walmart, etc). Combined with browser caching, the page will load all of the stuff it has very quickly.

This functionality has been in php for awhile, and performance expert
Steve Souders notes on his site that while the gains can be quite significant, there are many issues that people run into when trying to 'Flush the document early'. (he even created a series of test pages to show how it works, and the problems related to gzip, parallel downloads, etc)

You can see a bit more of his chapter from the book 'Even Faster Websites' on google books but I recommend buying both of Steve's books, as well as High Performance javascript by Nicholas Zakas. (of all the programming books i buy that instantly become stale..books on performance do not)