# Cache\_sweeper problem deleting cache

**URL:** <https://www.ruby-forum.com/t/cache-sweeper-problem-deleting-cache/155405>\
**Category:** Rails\
**Created:** [December 11, 2008, 3:01pm UTC](https://www.ruby-forum.com/t/cache-sweeper-problem-deleting-cache/155405 "2008-12-11T15:01:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [December 11, 2008, 3:01pm UTC](https://www.ruby-forum.com/t/cache-sweeper-problem-deleting-cache/155405/1 "2008-12-11T15:01:40Z")

</div>

i want to caching my rss feed, this work well,  
but i can t delete the generated cache with cache\_sweeper:

my feed rss generated by events archive, the public controller:

###### START CODE

class RssController \< ApplicationController  
caches\_page :nextevents  
def nextevents  
@next\_events = Event.find(:all)  
response.headers[‘Content-Type’] = ‘application/rss+xml’  
respond\_to do |format|  
format.xml  
end  
end  
end

###### END CODE

no my environment.rb:

###### START CODE

# … other code …

config.load\_paths += %W(#{RAILS\_ROOT}/app/sweepers)

# … other code …

###### END CODE

i make the dir /sweepers and file inside rss\_sweeper.rb:

###### START CODE

class RssSweeper \< ActionController::Caching::Sweeper  
observe Event  
def after\_create(event)  
expire\_cache\_for(event)  
end  
def after\_update(event)  
expire\_cache\_for(event)  
end  
def after\_destroy(event)  
expire\_cache\_for(event)  
end  
private  
def expire\_cache\_for(record)  
expire\_page ( :controller =\> ‘rss’, :action =\> ‘nextevents’)  
end  
end

###### END CODE

on my administation controller:

###### START CODE

class Admin::EventsController \< ApplicationController  
cache\_sweeper :rss\_sweeper, :only =\> [:create, :update, :destroy]

# … admin crud actions code …

end

###### END CODE

I suppose the cache\_sweeper don’ t work because it run in the sublevel  
administration module (Admin).  
some suggestion?
