Wycats is a great guy and contributes a ton to the Ruby community, but I have to say...there's really not much here that's new or insightful.
Set your headers, gzip content, and split assets across domains, yes, but - "Your pages will load faster with Rails"? Somehow the headline doesn't seem appropriate.
Hey @cscotta: This is just the first part of a few posts on this topic. The important part of the post is that Rails handles most of the heavy lifting for you. "Split assets across domains" sounds like it's a snap, but if you already have a large application and want to add it, it can be quite painful. The point is that with Rails, it's literally just a matter of adding a single line in your configuration and all your existing assets URLs will come along for the ride.
Same with far future expires. If you just set your headers to the far future, you'll be stuck with outdated content on the client that you can't control. If you use Rails, without doing a single additional thing, your asset URLs come prebaked with cache-busting behavior that operated in the background with no additional work by you.
There are a few cases where it's actually true depending on your host. For instance, if you use a Rails hosting provider, your image_tag, javascript_include_tag, and css_link_tag, you will get the benefit of far-future expires for free. This is not really specific to any particular Rails hosting provider; they all know that since Rails provides the cache-busting infrastructure, they can be aggressive about client-side caching.
Yes, the title is very misleading. As for the op protesting its because Rails makes its easy to do those things then surely that should be reflected in the name of submission - 'Built in Rails functionality helps page load'
I would also say the title is very presumptuous; claiming to make all pages load faster is an unachievable goal & clearly an exaggeration.
Is it? Do you have pages that don't include assets? No JavaScript? No CSS? No images? If so, then I think you're right. Otherwise, built-in Rails functionality will make all your pages faster.
The problem with the title "Your Pages Will Load Faster With Rails" is that it implies that Rails alone will make your pages load faster, and/or that Rails alone will make your pages load faster than they already are.
All of the speedup suggestions outlined in your article can also be handled easily - easier than Rails or not, I don't know - in other languages and frameworks as well. There is nothing about any of these items that only Rails can handle - heck half of them don't even have anything to do with your choice of server-side frameworks.
The main point of your article is "How Rails can make it easy to make your pages load faster".
claiming to make all pages load faster is an unachievable goal & clearly an exaggeration.
No, it is not. This is a claim which is testable and measurable, and for reasonable assumptions, you can predictably, measurably, and in a reproducible fashion improve page load times by implementing the YSlow recommendations.
If you have the following line of code in application.rhtml:
P.S. Explanation for non-Rails users: the above code causes the five specified Javascript files to be concatenated into "all.js" the first time any page on the Rails site is rendered, and all pages load all.js rather than loading the five Javascript files. This cuts the overhead of four HTTP request/response cycles from the page. It gives an obvious, measurable impact to page load times, and plays well with another braindead easy optimization "set your HTTP server to gzip outgoing textual content (including Javascript)".
What i'm trying to get over here is that if your site already uses all of these techniques and more while running on something faster than rails then you will not make the page faster, and thats what the title claims.
Expiry headers can just as easily be setup in your apache config and I can't think of any modern language that can't access file modification times.
A simple config for multiple resource domains is nice; but I'm not a fan of helper functions. javascript_include_tag just isnt as clear as <script src="/location/of/file"></script>
You have to set up the Expires header and modify every asset tag to include a cache-busting query string. Doing this via HTML parsing in Apache is extremely non-performant. Manually adding the mtime query string to every asset reference is possible but tedious and yet another thing to think about while building your app (resulting in a very-close-to-0 use of the technique outside of explicit framework support).
The lack of tediousness is the feature. When using Rails, you aren't required to know much about what's going on in order to get the benefits. And that results in an almost universal level of usage.
There's a lot of additional help that a framework can offer for the client-side if you use its helpers, and that help can be tuned over time as the best practices themselves get refined.
Speaking of which; when advising to use multiple domains should really mention not to go overboard on the number you use.
Too many alternative domains and you will get a new warning from yslow. Every time you pull from a new domain, this will incur a dns lookup, might even end up with the page going slower because them.
Yehuda already replied, but allow me to summarize: the point is that Rails will do these things automatically, without developers having to think about them. This means that, unless you are doing all the things Rails 3 will give you for free, it's true that "your pages will load faster with Rails"---thus fulfilling the titular promise.
I'd say download Firebug, YSlow, and Google's PageSpeed and let that be your guide, as these suggestions are helpful, but just the tip of the iceberg.
A YSlow feature that is new (at least to me) is its JavaScript tab. It's not related to performance exactly, but it will run your JS through jslint, minify, beautify it (if it's in a gnarly style). Great stuff.
The big point of emphasis for me from your post was that, usually, the front-end is the performance sink. A lot of web developers don't seem to get that, and will spend their time optimizing PHP loops (assuming they are not hitting the disk in the middle of that loop...).
I always tell my developers:
1) Measure, measure, measure.
2) Then, apply Amdahl's Law.
How did you read that into what I wrote? According to Steve Souders (YSlow), 80% of the time spent waiting for a page to load happens on the client. Rails makes it really easy to cut down significantly on that time. The question of server-side performance is entirely orthogonal (and not actually a "problem" for Rails at all; Rails provides significant server-side performance tools as well).
Rails is still just as slow as it ever was. According to YDN Best Practices (http://developer.yahoo.com/performance/rules.html), 80% of response time is spent on the front end. These techniques are for implementing common best practices (as measured by YSlow) that every site should follow.
Slightly off-topic, but the article pokes fun of older versions of IE because they only run two concurrent HTTP requests to a host at a time. That is actually the only instance where IE follows standards correctly: http://awurl.com/eWXb3NvtK
Part of it is a product of how difficult it is to be standards compliant with web technology, and perhaps I made an overbearing comment, but I'm still bitter with how IE held the web back for so many years out of apathy.
What, no one got the irony of the server(s) hosting a blog post about how to increase page load performance was down for maintenance in the middle of the day?
34 comments
[ 3.2 ms ] story [ 83.2 ms ] threadSet your headers, gzip content, and split assets across domains, yes, but - "Your pages will load faster with Rails"? Somehow the headline doesn't seem appropriate.
Same with far future expires. If you just set your headers to the far future, you'll be stuck with outdated content on the client that you can't control. If you use Rails, without doing a single additional thing, your asset URLs come prebaked with cache-busting behavior that operated in the background with no additional work by you.
Whether or not Rails makes it easy to implement these suggests or if another framework makes it harder/easier is another discussion.
I would also say the title is very presumptuous; claiming to make all pages load faster is an unachievable goal & clearly an exaggeration.
Looking at http://www.alexa.com/topsites for example, which of those would you think Rails could make faster?
All of the speedup suggestions outlined in your article can also be handled easily - easier than Rails or not, I don't know - in other languages and frameworks as well. There is nothing about any of these items that only Rails can handle - heck half of them don't even have anything to do with your choice of server-side frameworks.
The main point of your article is "How Rails can make it easy to make your pages load faster".
No, it is not. This is a claim which is testable and measurable, and for reasonable assumptions, you can predictably, measurably, and in a reproducible fashion improve page load times by implementing the YSlow recommendations.
If you have the following line of code in application.rhtml:
javascript_tag "prototype", "scriptaculous", "shopping-cart", "color-picker", "mysite-functions"
and you add these 16 characters
, :cache => true
then every page on your site now loads faster.
P.S. Explanation for non-Rails users: the above code causes the five specified Javascript files to be concatenated into "all.js" the first time any page on the Rails site is rendered, and all pages load all.js rather than loading the five Javascript files. This cuts the overhead of four HTTP request/response cycles from the page. It gives an obvious, measurable impact to page load times, and plays well with another braindead easy optimization "set your HTTP server to gzip outgoing textual content (including Javascript)".
A simple config for multiple resource domains is nice; but I'm not a fan of helper functions. javascript_include_tag just isnt as clear as <script src="/location/of/file"></script>
There's a lot of additional help that a framework can offer for the client-side if you use its helpers, and that help can be tuned over time as the best practices themselves get refined.
Too many alternative domains and you will get a new warning from yslow. Every time you pull from a new domain, this will incur a dns lookup, might even end up with the page going slower because them.
A YSlow feature that is new (at least to me) is its JavaScript tab. It's not related to performance exactly, but it will run your JS through jslint, minify, beautify it (if it's in a gnarly style). Great stuff.
I always tell my developers: 1) Measure, measure, measure. 2) Then, apply Amdahl's Law.
Part of it is a product of how difficult it is to be standards compliant with web technology, and perhaps I made an overbearing comment, but I'm still bitter with how IE held the web back for so many years out of apathy.