partial-caching-russian-doll
🗃️ Tip: Implement Russian Doll Caching for Partials
Wrap nested partials in cache
blocks using their model objects to achieve automatic key generation and expiration. This technique ensures that changes in deeply nested subviews only refresh their respective fragments without busting parent caches.
Example:
<% cache @article do %>
<%= render partial: 'header', locals: { article: @article } %>
<% cache article.comments do %>
<%= render partial: 'comments/comment', collection: article.comments %>
<% end %>
<% end %>