Action/Fragment Cache for a Ruby and Rails Newbie


#1

Folks,

I am working on a small rails project which has a few actions but with
intensive db and rendering.
I looked at caching models and because of scalability and
authentication needs I will have to use action cache or fragment
cache.

My problem/question is the following: I use a default layout for all
my actions (which cannot be cached) and for source code clarity I put
most of the activerecord db queries and objects processing in the
controller. Doing fragment cache works great but then it stills
execute the action code which is useless because there is no rendering
anymore using it thanks to fragment cache. The solution would be to
use action cache, but then my default layout is cached which is not
what I want as it shows up personal information (and adding a new
parameter in the route for the user is not an alternative).

Something wrong in my understanding?
Can you give me a hand on this?
Is my controller/view organisation correct?
Any good story about that?

My main concern at that level is to speed up the average connection/s
per server.

Thank you very much in advance for your help,
Cheers,
Eric.


#2

Eric,

for source code clarity I put most of the activerecord db queries
and objects processing in the controller.
Doing fragment cache works great but then it stills execute the
action code which is useless because there is no rendering

If you apply the
“Skinny Controller, Fat Model”
http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model
pattern, you can move those costly operations to the view where there
can be cached by fragment and page caching.

Alain

blog.ravet.com