Making Rails fragment caching usable

December 13, 2007 Link to post  Permalink

Caching is a real pain to get right. Actually, the caching part is quite easy with Rails, its the expiry that causes the trouble. All the simple cases are easy! Its when you have a page with various pieces of data, with different expiry conditions that the trouble starts.

I’ve written some code to use versioning in my fragment cache that is working for my most recent project. This technique relies on using Memcache to work correctly. I’ve been thinking about packaging this up as a plugin and releasing it. Luckily, I never got around to it.

Today, I read this post on how to do better caching. This plugin has documentation and tests, and is easier to configure than mine.

Go check it out.

http://blog.evanweaver.com/articles/2007/12/13/better-rails-caching/