views:

292

answers:

1

I have a set of largely static pages which I'd be happy to page cache for relatively long periods apart from the fact that their layout includes a much more dynamic header.

The most promising idea so far seems to be using action caching without layout :-

class SomethingController < ApplicationController

  caches_action :index, :layout => false

end

Then at least the main content of the page is cached. Does that make sense?

Or would I be better off doing something else, e.g. fragment caching, server-side include, etc...?

+2  A: 

What I have done is use page caching, and then make an AJAX call to fetch either:

  1. The entire header.
  2. Specific parts of the header that are dynamic.

Also, if you are just looking to include the users name, a better way exists. Simply store their name in a cookie and then use javascript to display it in the header. With no cookie, show a link to go login or register.

Scott Miller