# Before\_filter multiple cache hits with index action

**URL:** <https://www.ruby-forum.com/t/before-filter-multiple-cache-hits-with-index-action/146011>\
**Category:** Rails\
**Created:** [August 16, 2008, 2:13am UTC](https://www.ruby-forum.com/t/before-filter-multiple-cache-hits-with-index-action/146011 "2008-08-16T02:13:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nateleavitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3bc359/32.png) [@nateleavitt](https://www.ruby-forum.com/u/nateleavitt)\
**Post date:** [August 16, 2008, 2:13am UTC](https://www.ruby-forum.com/t/before-filter-multiple-cache-hits-with-index-action/146011/1 "2008-08-16T02:13:16Z")

</div>

I have an association between users and subscriptions.

I’m using REST so in my subscriptions controller I’m using a  
before\_filter which loads the current user from cache. However, I  
notice when running the index action that I have a cache hit in the logs  
4 times which I’m assuming represents the 4 actions in my controller.  
Does the controller run the before\_filter for each action before the  
actions are actually run?

---

<div class="post-metadata">

**Author:** ![nateleavitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3bc359/32.png) [@nateleavitt](https://www.ruby-forum.com/u/nateleavitt)\
**Post date:** [August 16, 2008, 3:30am UTC](https://www.ruby-forum.com/t/before-filter-multiple-cache-hits-with-index-action/146011/2 "2008-08-16T03:30:20Z")

</div>

On 16 Aug 2008, at 01:13, Nate L. wrote:

> I have an association between users and subscriptions.
> 
> I’m using REST so in my subscriptions controller I’m using a  
> before\_filter which loads the current user from cache. However, I  
> notice when running the index action that I have a cache hit in the  
> logs  
> 4 times which I’m assuming represents the 4 actions in my controller.  
> Does the controller run the before\_filter for each action before the  
> actions are actually run?

I’ve certainly never seen that happen and it’s not what’s supposed to  
happen.

Fred
