« Performance Freak's View on RailsConf 2008 | Main | Why You Should Use 'Cache-Control: public' for Caching to Work with SSL »

July 02, 2008

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83451c8d369e200e5539acc6c8834

Listed below are links to weblogs that reference The Road to Hell Is Paved With Caching:

Comments

Chris Heald

Honestly, you're really best off using memcached with Rails' sweepers. It's more work, yes, but it's well worth it. memcached scales across multiple servers, so you can cache for an entire cluster as opposed to per-machine, and it's in-memory access, which avoids the ever-so-slow disk seek time.

If you're clever about your cache key naming, you can have an even easier time of it. For example, if you have a page of blog posts, and you cache by blog post, then you need a SQL query to fetch the timestamp of the most recent post (which should be blazing fast with a properly indexed column). Once you have that, you can build a cache key to check for ("blog_index_7.2.2008.14.45.14"). If a new post has been added, then the cache key changes and a new page fragment is cached. memcached automatically expires old fragments once it runs out of room, so your caching expiry happens transparently without any need for you to do anything.

As Phil Karlton said, "there are only two hard things in Computer Science: cache invalidation and naming things". It's worth doing it right.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Buzzletter

  • Hear about our new Ruby on Rails performance improvements, hacks, recipes, plugins & more. Enter your email below