I’m using fragment cache but i have inline code that is user specific like:
<% cache @page do %>
stuff here
<% if current_user %>
user specific
<% end %>
more here
<% end %>
So i want to exclude the several blocks of code that are user specific. Is there a way to do that in Rails or should i make an if statement in the beginning and make different caches for logged users and regular visitors? (i will have major duplication of code this way).
For per-user fragments, you can put models in array an array:
Rails will make a cache-key out of them, like:
This way your fragments will be invalidated on a user/page update since the time-stamps are coming from their
updated_at(see cache_key for details).