regenerating cached pages automatically

To answer your questions…

  1. The “proper” way of using the cache is not to generate a new cached page. If you edit the page again before any user visited it, then you’d have to needlessly empty the cached version again and repropagate it.

  2. I dunno. Have you tried? :slight_smile:


2. render_to_string is my new best friend :slight_smile: (however there are limitations, such as, I can only get it working after converting all of my templates to partials as I can't seem to get variables into the templates)   

I'm gonna introduce you a new best friend then :wink:

render_component_as_string (beats me why the difference in the naming using "as" and not "to" breaking the POLS, but that's not the point here) will not just render the view but it will call the real action and then render the result as a string. This way you don't have to worry about partials or about coding your actions in a different way. Just code them as usual, and use them as components.

Using components is not recommended sometimes because it will introduce some overhead in your system. Calling a component from another action means Rails has to instantiate a bunch of new objects, but for administrative/batch tasks like cleaning/reloading cache it seems a good option to me.


javier ramirez