Scott Holland wrote:
I have a sidebar on every page of my site which is part of my layout.
This sidebar contains a list of the last 10 updated threads in the
I have a ‘setup_sidebar’ action in the application controller and a
‘before_filter’ in every controller to populate the variables in the
My question is – how on Earth do I cache this sidebar??
Would I use fragment caching? If so – how would I expire these?
Thanks for your help
Yup, fragment caching's the way to go. I use the timed_fragment_caching plugin. Obviously if the sidebar is common across controllers (e.g. a tag_cloud) you don't need to generate a cached copy for each of the controllers. See the Rails Envy blog for an excellent run through on fragment caching -- http://www.railsenvy.com/2007/3/20/ruby-on-rails-caching-tutorial-part-2
Hope this helps