cache
- 1.0.0 (0)
- 1.1.6 (0)
- 1.2.6 (0)
- 2.0.3 (9)
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0 (1)
- 3.0.9 (-1)
- 3.1.0 (-1)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (38)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (15)
- 5.1.7 (4)
- 5.2.3 (3)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- 7.2.3 (0)
- 8.0.0 (3)
- 8.1.1 (0)
- What's this?
cache(name = {}, options = nil, &block)
public
This helper to exposes a method for caching of view fragments. See ActionController::Caching::Fragments for usage instructions.
A method for caching fragments of a view rather than an entire action or page. This technique is useful caching pieces like menus, lists of news topics, static HTML fragments, and so on. This method takes a block that contains the content you wish to cache. See ActionController::Caching::Fragments for more information.
Examples
If you wanted to cache a navigation menu, you could do the following.
<% cache do %> <%= render :partial => "menu" %> <% end %>
You can also cache static content…
<% cache do %> <p>Hello users! Welcome to our website!</p> <% end %>
…and static content mixed with RHTML content.
<% cache do %> Topics: <%= render :partial => "topics", :collection => @topic_list %> <i>Topics listed alphabetically</i> <% end %>

