5

I have an app on which I greatly improved the response times by making use of caching.

I'm Russian doll caching fragments, and one fragment renders a couple of (nested) partials. Everything seems to be working like it should, but some of my included partials are made out of an interpolated string. For those partials, I get a caching error in my error log:

Couldn't find template for digesting: path/to/#{my.calculated.partial.name}

I've spent some time on Google, and the only thing I find is that a lot of people want to have the digesting switched off. So I've basically got a couple of questions:

  1. Is there a way to fix this particular issue? (i.e. having cache digests for the actual "evaluated" partial names)?

    • I can imagine the answer to this to be "no", since the cached version of a page isn't executing any code, and as such, interpolated strings can't
  2. More general: why would I want to enable or disable cache digests? What's their purpose?

  3. How would you suggest I work around these errors (if not solved by 1.)?

Update:

As requested, an example of a view that gives me this error would be:

-cache ['survey', @survey], expires_in: expire_period
  [...]
  -cache ['survey_questions', @survey]
    -@survey.questions.each do |q|
      =render "field_types/#{q.field_type.type.underscore}", question: q, f: f

For instance when a field type is 'text input', it renders field_types/_text_input.html.haml. This all works great. The error I would get in my log is then:

_Couldn't find template for digesting: field_types/field_types/#{q.field_type.type.underscore}_

Pelle
  • 6,423
  • 4
  • 33
  • 50
  • Add some code snippets to reveal underlying problem. – blelump Dec 03 '14 at 21:07
  • @blelump Snipped added. Please help me understand what this clears out that wasn't clear in my initial question; I'd like to learn to get it right the first time. :) – Pelle Dec 04 '14 at 15:32
  • Cache digests are like md5 on the whole template and when the content is change the cache key is changed. – Ivailo Bardarov Dec 17 '14 at 20:23
  • The caching key for app/views/projects/show.html.erb will be something like views/projects/605816632-20120810191209/d9fb66b120b61f46707c67ab41d93cb2. That last bit is a MD5 of the template file itself and all of its dependencies. It'll change if you change either the template or any of the dependencies, and thus allow the cache to expire automatically. from: https://github.com/rails/cache_digests – Ivailo Bardarov Dec 17 '14 at 20:32
  • I totally understand that. It doesn't address my issue though, does it? – Pelle Dec 18 '14 at 17:04
  • 1
    I have the same problem using Rails 4, didn't have this with Rails 3 + cache digest gem – netwire May 10 '15 at 17:50
  • possible duplicate of [Issues using Russian Doll Caching with Template Inheritance](http://stackoverflow.com/questions/17154052/issues-using-russian-doll-caching-with-template-inheritance) – Brad Werth Jul 03 '15 at 05:32

0 Answers0