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?