プロファイル/ show.html.erb
<% cache(@profile) do %> #this is the profile info and the cache key expires properly when @profile.full_name changes
<%= @profile.full_name %>
.....
<% end %>
<% if @profile.user.products.any? %> #not nested in the previous cache;
#products belonging to the profile are listed with this code under the profile info
<%= render 'products/profile_products' %>
<% end %>
_profile_products.html.erb
<% cache(['profile-products', @profile_products.map(&:id), @profile_products.map(&:updated_at).max]) do %>
<%= render partial: "products/profile_product", collection: @profile_products, as: :product %>
<% end %>
_profile_product.html.erbは
のキャッシュキーを変更してみてください
_profile_p roducts.html.erb
<% cache(['profile-products', @profile_products.map(&:id), @profile_products.map(&:updated_at).max, @profile_products.map{|pp| pp.user.profile.updated_at.to_i }.max]) do %>
<%= render partial: "products/profile_product", collection: @profile_products, as: :product %>
<% end %>
問題は、ユーザーがプロファイル名を更新したときにリスト全体を含むcacheフラグメントが期限切れにならないことです。
関連するユーザープロファイルのupdated_at
の最大値をキャッシュキーに追加すると、ユーザーがプロファイルを更新するとキャッシュフラグメントが期限切れになります。