Russian Doll Caching in Rails 4

Russian Doll Caching in Rails 4

Rails 4 nudges developers toward more pervasive use of fragment caching (and the so-called “russian doll caching” strategy of deeply nesting fragment caches) with the introduction of ActionView::Digestor and on-by-default appending of template digests to fragment cache keys. Though actually pretty simple in its implementation, this feature (paired with correct use of ActiveRecord’s “touch” relation option) solves most of the formerly enormous headaches you’d encounter (and still do today with pretty much every other framework) trying to implement an advanced caching strategy with largely dynamic content. I’ve been working with this technique for more than half a year now (initially using the Rails 3 “cache_digests” gem , which implemented the same functionality now available through ActionView::Digestor in Rails 4).

At Chloe + Isabel we have weekly developer talks. Below are the slides from one I gave detailing the “russian doll” caching strategy in enough depth, I feel, to bring most Rails developers to a strong enough understanding to work with the techinique.

 

Nicholas

Hi! I'm Nicholas and I like building stuff. I'm software consultant working primarily with web technologies. I write here on related topics such as the Ruby on Rails web framework and DevOps solutions, in addition to travel and other matters of personal interest. I keep a homepage at nicholas.zaillian.com and am available for contract work (both remote and on-site depending on location. Send an email to hi@hackernotes.io).

No Comments

Leave a Comment

Please be polite. We appreciate that.
Your email address will not be published and required fields are marked