Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8497133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:02:40+00:00 2026-06-11T00:02:40+00:00

I want to do some heavy caching (russian doll caching as DHH calls it),

  • 0

I want to do some heavy caching (russian doll caching as DHH calls it), but I’m not sure how to do it, because I have so much content that depends on the user and the attributes he has.

How would you do RDC on a view like this?:

<% if signed_in? %>
  <div class="timeline">
    <%= link_to image_tag(current_user.avatar), designer_path(current_user), :class => "avatar topimg" %>
    <%= content_tag(:span, "your profile", :class => "description") %>
    <%= link_to "", new_design_path, :class => "upload icon-upload" %>
    <%= content_tag(:span, "upload a new design", :class => "description") %>
    <%= link_to "", designer_path(current_user)+"/favorites", :class => "upload icon-star" unless current_user.followees_by_type("design").blank? %>
    <%= content_tag(:span, "designs you've favorited", :class => "description") unless current_user.followees_by_type("design").blank? %>
    <%= content_tag(:span, current_user.current_invites, :class => "invites_count") unless current_user.current_invites <= 0 || current_user.full_member == false %>
    <%= link_to "", "#", :class => "invite icon-plus "+("blue" unless current_user.current_invites == 0).to_s unless current_user.current_invites < 0 || current_user.full_member == false  %>
    <%= content_tag(:span, "invite a friend ("+current_user.current_invites.to_s+" invites left)", :class => "description") unless current_user.current_invites < 0  %>
    <%= content_tag(:span, activity, :class => "activity_count") unless activity == 0 %>
    <%= link_to "", designer_path(current_user)+"/statistics", :class => "upload icon-activity "+("blue" unless activity == 0).to_s unless activity == 0 %>
    <%= content_tag(:span, ("your activity ("+pluralize(activity, 'new thing')+")"), :class => "description") unless activity == 0%>
  </div>
<% else %>
  <%= link_to raw('<i class="icon-twitter icon-font"></i><span>login with twitter</span>'), "/auth/twitter", :class => "btn btn-twitter grey-tweet" %>
<% end %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:02:42+00:00Added an answer on June 11, 2026 at 12:02 am

    You can wrap the whole thing in one big cache block as follows:

    <% cache ['timeline', @user] do %>
      ...
    <% end %>
    

    This will cache it using the key timeline/#{@user.cache_key}. The cache_key contains the record id and updated_at by default, so the cached fragment is automatically invalidated* once the user record is updated.

    Please note that if you use relations in your fragment (such as the followers), you should touch the user object every time one of the relations is updated. This can be accomplished automatically by setting :touch => true on the relation, as such:

    class Follower
      belongs_to :user, :touch => true
      ...
    

    (*) Please note that the outdated cache key is not really invalidated, it will just no longer be used. You should set an expiry on all cache keys or do some regular housekeeping to avoid overflowing your cache.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some very heavy code to develop and want to make some calculations
May be it sound dumb but if I want some computed value from other
Semantically, I want an itemized list, but visually I just want some space. How
I have a test project requiring some heavy jars which i put in ${M2_HOME}\test\src\main\resources\
I have implemented some computationaly heavy functions into my application. Depending on the type
I want to create unorder list. UIwebView is good but it's very heavy (there
I have some PDF template (with header and footer). I want to generate documents
I have a heavy asp.net page. While it renders, some images come in the
I have a large set of files for which some heavy processing needs to
I have a windows service that invokes some heavy image processing whenever a user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.