It’s pretty common to have a front page that has content that is very cacheable, except for a little section with something like “signup” or “my page”, depending on whether the user is logged in or not. It would be very nice to have a handy solution in rails for this problem, which seems to be a fairly common question.
Here’s my stab at an answer:
However, I’m not entirely happy with it because of the very hacky approach taken to make the
render_as_string work – I have to fiddle with an instance variable in the controller:
controller.instance_variable_set '@performed_render', false
Not good. In the thread linked to above, Paul Gustav posts a link about a system for having two different cached pages, but that’s not entirely satisfying either, because it gets you from 1 version to 2 versions, but going beyond doesn’t look real appetizing.
It would be a very nice problem to solve once and for all with a clean solution.