Using Rails 3.1.1 and Heroku.
I believe this should be a fairly easy fix but I cannot find (and easily verify) how to do this. I have a very slow controller (6 sec)
You can achieve this with fragment caching like below:
def show
if !fragment_exist?("main_content")
@products = Product.all
@users_count = User.count
end
@random_products = Product.order("RANDOM()").limit(10)
end
show.html.erb
<% cache("main_content") do %>
<%= @users_count %>
<% @products.each do |product| %>
<%= product.name %>
<% end %>
<% end %>
<% @random_products.each do %>
<%= product.name %>
<% end %>