6 ms·
Your Pages Will Load Faster With Rails
- xsc 17y agoThis isn't just specific to Rails. -Use Far-Future Expires -GZip Components -Split Components Across Domains
- wycats 17y agoOf course not. But Rails makes it dead easy!
- cscotta 17y agoWycats 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.
- wycats 17y agoHey @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.
- brown9-2 17y agoThe title is misleading though because it makes it sound as if all you need to do to make your pages load faster is switch to Rails. Whether or not Rails makes it easy to implement these suggests or if another framework makes it harder/easier is another discussion.
- wycats 17y agoThere 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.
- charlesmarshall 17y agoYes, 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.
- wycats 17y agoIs 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.
- charlesmarshall 17y agoYes, it is presumptuous. Do you think that Rails could make every & any website in the world faster? Looking at http://www.alexa.com/topsites http://www.alexa.com/topsites for example, which of those would you think Rails could make faster?
- brown9-2 17y ago
- charlesmarshall 17y agoExpiry 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>
- wycats 17y agoYou 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).
- charlesmarshall 17y agoYes, both are very tedious, but both possible and done by other frameworks.
- wycats 17y agoThe 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.
- wycats 17y agoAlso, the reason for using javascript_include_tag instead of <script> is that the actual script tag would look like <script src="http://assetsN.yourapp.com/location/of/concatted_js_files.js?mtimestamp></script> http://assetsN.yourapp.com/location/of/concatted_js_files.js...; 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.
- 17y ago
- mhartl 17y agoYehuda 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.
- mncaudill 17y agoI'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.
- wycats 17y agoTotally the tip of the iceberg. I plan to post some more of the built-in Rails support for other YSlow recommendations in the coming weeks.
- mncaudill 17y agoThe 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.
- idlewords 17y agoThis is just an ad for the guy's hosting business.
- wycats 17y agoHuh?
- technoweenie 17y agoWell yes, it's on the guy's host business' blog.
- vlucas 17y agoKind of funny how the solution for making Rails faster is offloaded to the client side.
- wycats 17y agoHow 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).
- technoweenie 17y agoRails is still just as slow as it ever was. According to YDN Best Practices (http://developer.yahoo.com/performance/rules.html 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.
- m0th87 17y agoSlightly 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 http://awurl.com/eWXb3NvtK
- brown9-2 17y agoReally, there is not a single other standard that IE follows correctly?
- m0th87 17y agoWhile the remark wasn't meant to be taken literally, it's pretty close to true: http://www.webdevout.net/browser-support-summary http://www.webdevout.net/browser-support-summary 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.
- ismarc 17y agoFunny, The system is down for maintenance as of 14:26 PST. It'll be back shortly.
- ismarc 17y agoWhat, 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?