Archive

Archive for April 27th, 2009

:cache => true

April 27th, 2009 mahesh No comments

That is all it took to take my site from F grade to B and make my site faster by 1 second almost! So, if you have a rails app, go ahead and add :cache => true to your stylesheet_link_tag and javascript_include_tag in your view files. This is all I added into my application.html.erb

<%= stylesheet_link_tag "home", :media => "all", :cache => true %>
<%= javascript_include_tag :all, :cache => true %>

All rails does is collapses all your javascript (and stylesheet) files into single file. I have 11 javascript files and 3 css files. With this, I reduced the number of calls by 12 and that gave a good one second improvement! Not bad ha? Also, that one second was pretty consistent with/without firefox caching.

After this, I tried using asset_packager plugin to see if I get any more improvement. But, I didn’t really see any. Basically, that minifies your files by combining everything into one file and removing new line character and stuff.

The video tutorial had a few more suggestions like using CDN which clearly is not something I would like to explore at this point because it costs money.

That’s all for now. Stay tuned for more improvements as I go through next tutorials.

Cheers,
Mahesh Murthy

Categories: Uncategorized Tags: