# Action/Fragment Cache for a Ruby and Rails Newbie

**URL:** <https://www.ruby-forum.com/t/action-fragment-cache-for-a-ruby-and-rails-newbie/103327>\
**Category:** Rails\
**Created:** [May 4, 2007, 10:53am UTC](https://www.ruby-forum.com/t/action-fragment-cache-for-a-ruby-and-rails-newbie/103327 "2007-05-04T10:53:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric.c](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e95f7d/32.png) [@eric.c](https://www.ruby-forum.com/u/eric.c)\
**Post date:** [May 4, 2007, 10:53am UTC](https://www.ruby-forum.com/t/action-fragment-cache-for-a-ruby-and-rails-newbie/103327/1 "2007-05-04T10:53:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eric.c](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e95f7d/32.png) [@eric.c](https://www.ruby-forum.com/u/eric.c)\
**Post date:** [May 6, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/action-fragment-cache-for-a-ruby-and-rails-newbie/103327/2 "2007-05-06T16:33:44Z")

</div>

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”  
[Buckblog: 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](http://blog.ravet.com)
