Topic: ActiveRecord Caching

I have a rails app that gets a ton of hits on a particular "show" page, which has to gather info from the DB for each request.  the table has 300,000 records.  I'd like to cache the most recent records (maybe 1000), and then hit the db if the record is not in the cache.

How can this be accomplished?

Re: ActiveRecord Caching

It depends, do you want to avoid having the query the database altogether or do you just want to cache the more complicated "sub-queries" that your post page calls?

If it's the first then page caching is probably the way to go, if the second then fragment caching would help. If you want to cache only the results from the database you can also use query caching but that's probably not the most efficient way to go here.

Check out Ryanb's Railscasts on caching first, to get an idea what the options are: http://railscasts.com/tags/18