Caching and sweeping pages. RSS feeds behave funny

This commit is contained in:
Alexey Verkhovsky 2005-09-11 18:02:56 +00:00
parent c4f593151e
commit cc99790a4a
2 changed files with 28 additions and 2 deletions

View file

@ -0,0 +1,24 @@
class RevisionSweeper < ActionController::Caching::Sweeper
observe Revision, Page
def after_save(record)
if record.is_a?(Revision)
expire_caches(record.page)
end
end
def after_delete(record)
if record.is_a?(Page)
expire_caches(record)
end
end
private
def expire_caches(page)
expire_page :controller => 'wiki', :web => page.web.address,
:action => %w(show published), :id => page.name
expire_page :controller => 'wiki', :web => page.web.address,
:action => %w(authors recently_revised list rss_with_content rss_with_headlines)
end
end

View file

@ -6,7 +6,8 @@ require 'zip/zip'
class WikiController < ApplicationController
# TODO implement cache sweeping
caches_page :show, :published
caches_page :show, :published, :authors, :recently_revised, :list, :rss_with_content, :rss_with_headlines
cache_sweeper :revision_sweeper
layout 'default', :except => [:rss_feed, :rss_with_content, :rss_with_headlines, :tex, :export_tex, :export_html]
@ -194,6 +195,7 @@ class WikiController < ApplicationController
redirect_to_page @page_name
rescue => e
flash[:error] = e
logger.error e
flash[:content] = @params['content']
if @page
@page.unlock