Caching and sweeping pages. RSS feeds behave funny
This commit is contained in:
parent
c4f593151e
commit
cc99790a4a
2 changed files with 28 additions and 2 deletions
24
app/controllers/revision_sweeper.rb
Normal file
24
app/controllers/revision_sweeper.rb
Normal 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
|
|
@ -6,8 +6,9 @@ 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]
|
||||
|
||||
def index
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue