Questions tagged [russian-doll-caching]

The technique of nesting fragment caches to maximize cache hits is known as russian doll caching.

By nesting fragment caches, it ensures that caches can be reused even when content changes. When a change occurs to the top-most fragment cache, only that cache must be expired. Every nested cache of the parent can be reused, which provides a significant performance increase. A change to the most nested fragment cache would start a chain reaction to expire all parent caches.

23 questions
23
votes
2 answers

Structuring a Rails app for Russian Doll Caching with a has_many relationship

After studying DHH's and other blog articles about key-based cache expiration and Russian Doll Caching, I am still unsure how to handle one relation type. To be specific, a has_many relationship. I will share the results of my research on a sample…
9
votes
2 answers

Rails caching a paginated collection

Just doing some research on the best way to cache a paginated collection of items. Currently using jbuilder to output JSON and have been playing with various cache_key options. The best example I've seen is by using the latest record's updated_at…
James
  • 2,284
  • 1
  • 20
  • 29
6
votes
2 answers

How do I bust my cache key based on the params in the URL?

I have a Profile#Index view, where I render a partial like so: <% cache @profiles do %>
<% @profiles.to_a.in_groups_of(3, false).each do |profiles| %>
<%= render partial:…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
6
votes
1 answer

Rails Russian Doll Caching and N+1

From what i understand of Russian doll caching in Rails it would be detrimental to eager load related objects or object lists when we are doing RDC (Russian Doll Caching) because in RDC we just load the top level object from the database, and look…
6
votes
1 answer

Rails 4.0.0.0 Russian Doll Caching with belongs_to model

I have set up a cache in my model like def self.latest(shop_id) Inventory.where(:shop_id => shop_id).order(:updated_at).last end and in my view <% cache ['inventories', Inventory.latest(session[:shop_id])] do %> <% @inventories.each do…
markhorrocks
  • 1,199
  • 19
  • 82
  • 151
5
votes
2 answers

Why does this cache statement not write the key I expect?

I have this in my _profile.html.erb partial: <% cache [current_user.roles.first, profile, @selected_profile, params[:rating]] do %> Yet this is what I see in my server log: Read fragment…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
4
votes
1 answer

How can a deadlock occur when no row or table locks are set? (caused by rails ActiveRecord#touch)

I'm using Rails 4's template-caching features extensively. Lots of nested templates and touch: true on lots of models. Overall it has proven to be a comprehensive solution that is easy to reason about. I recently implemented a feature where multiple…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
3
votes
1 answer

Russian doll caching and permission-based links in view fragment

I've got a view that utilizes Russian Doll caching, where the whole collection of items is cached, and each item in the collection is cached individually within that cache. However, each item in the collection should show edit/delete links based on…
3
votes
1 answer

Issues using Russian Doll Caching with Template Inheritance

I have been using both Template Inheritance and Russian Doll Caching (using the cache_digests gem) independently of one another in select portions of a fairly complex Rails application, with much success. I am having difficulty using the two…
2
votes
2 answers

rails 4 fragment caching for different views

In my rails 4 app I'm trying to take off with caching, but I'm a bit confused thanks to the different versions of cache-key-settings, cache helpers and auto-expiration. So let me ask this through few examples. I don't move the examples to different…
2
votes
0 answers

Rails 4 redirect links to ip address on Redis

I have an interesting problem. I use Russian-doll cache (cache_digests) on Rails 4 with Redis. After a period time, most of the links on pages change like this: "domain/url" to "server_ip/url" It's fixed when I flush Redis. How can I solve this…
2
votes
0 answers

Russian Doll Cache Digest Partials Not Bubbling Up

From my understanding of Russian Doll caching with Cache Digests, in order to prevent us from having to version the fragments, if I update a child fragment the digest key should bubble up to expire it's parent. If this is correct I am having an…
2
votes
2 answers

How to keep caches warm using Russian Doll caching?

I've been experimenting with Russian Doll fragment caching on a Rails app, more specifically on its main Dashboard page. This is the first page the user sees after he logs in and is a great candidate for Russian Doll, since it contains many nested…
Luciano
  • 825
  • 1
  • 7
  • 10
1
vote
1 answer

Rails: Partly caching a nested form

I have a complex nested form which takes a few seconds to load when it's not cached. The hidden id fields look like this:
Railsana
  • 1,813
  • 2
  • 21
  • 30
1
vote
1 answer

rails4 double nested models russian-doll-caching

I have the following structure in my rails4 app for the posts. Users can comment on the post and replies can be written on the comments. I'd like to use russian-doll-caching with auto-expiring keys on the page, but I don't know how I should exactly…
1
2