I'm attempting to use a sweeper to clear the home page index action when a new article is published.
The home page cache is working fine in development environment and expires after 1 minute. However when an article is saved, the sweeper action is not triggered.
class HomeController < ApplicationController
caches_action :index, :expires_in => 1.minute
cache_sweeper :article_sweeper
def index
@articles = Article.published.limit(5)
end
end
class ArticleSweeper < ActionController::Caching::Sweeper
observe Article
def after_update(article)
expire_action(:controller => 'home', :action => 'index')
end
end
Either I've gone wrong somewhere or a different approach is needed to expire the home page cache.
My app uses ActiveAdmin to update articles, and Dalli for Memcache (as I'll be using Heroku).