# Can't expire cached pages

**URL:** <https://www.ruby-forum.com/t/cant-expire-cached-pages/126847>\
**Category:** Rails\
**Created:** [January 22, 2008, 7:59pm UTC](https://www.ruby-forum.com/t/cant-expire-cached-pages/126847 "2008-01-22T19:59:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [January 22, 2008, 7:59pm UTC](https://www.ruby-forum.com/t/cant-expire-cached-pages/126847/1 "2008-01-22T19:59:22Z")

</div>

For some reason I can not expire a cached page. I have created a  
sweeper file and I know that the proper methods are being called. I  
have also tried just moving the expire\_page call into the controller  
code, but it still doesn’t work.

The main page is cached with the following to create an index.html file  
in the public dir:  
class PublicController \< …  
caches\_page :index

def index  
@blog\_posts = Blog.find(:all, :limit =\> 10)  
end  
…  
end

The following is what I have in the Admin::BlogPostController class

class Admin::BlogPostController \< …  
cache\_sweeper :blog\_post\_sweeper, :only =\> [:create, :update,  
:destroy]  
…  
end

And here is the sweeper:  
class BlogPostSweeper \< …  
observe BlogPost

def after\_save  
expire\_cache :controller =\> “public”, :action =\> “index”  
end

end

As I mentioned earlier, I know that it is calling the sweeper method,  
but fails to delete the cached file.

Any ideas?

Thanks
