# Action Caching and After Filters

**URL:** <https://www.ruby-forum.com/t/action-caching-and-after-filters/182770>\
**Category:** Rails\
**Created:** [February 2, 2010, 5:00pm UTC](https://www.ruby-forum.com/t/action-caching-and-after-filters/182770 "2010-02-02T17:00:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5e925/32.png) [@lukec](https://www.ruby-forum.com/u/lukec)\
**Post date:** [February 2, 2010, 5:00pm UTC](https://www.ruby-forum.com/t/action-caching-and-after-filters/182770/1 "2010-02-02T17:00:42Z")

</div>

Hi there,

I’m using action caching, instead of page caching, because I’m using  
filters in my controller.

`
class CommunityProgramController < ApplicationController
before_filter :login_required
after_filter :log_request
caches_action :show
`

In the log:  
Cached fragment hit: views/site.com/community\_programs/1 (0.2ms)  
Filter chain halted as [#\<ActionController::Filters::AroundFilter:  
0x2a3a1540 …

I’m wondering if there’s a way to get after\_filters working with  
action caching. As far as I can tell what happens is, if an action has  
been cached, the caches\_action filter will halt the filter chain and  
spit back the cached result. This means that any after\_filters don’t  
get run.

Is there some way to still have the after filters run ?  
Are my assumptions correct about how this is working ?

Yes, I know I could change it to a before filter. I’ve done a little  
bit of performance testing and it appears that the gain I get in using  
action caching is cancelled out by needing log\_request to be a before  
filter instead of an after filter.

Thanks!

Luke
