Cache file_list Action

Also, slightly smarter cache expiry, upon uploading/deleting a file.
This commit is contained in:
Jacques Distler 2009-01-10 22:33:30 -06:00
parent 5c20871ec4
commit b9f5c32755
5 changed files with 17 additions and 5 deletions

View file

@ -16,9 +16,13 @@ module CacheSweepingHelper
end
end
%w(authors atom_with_content atom_with_headlines).each do |action|
%w(authors atom_with_content atom_with_headlines file_list).each do |action|
expire_action :controller => 'wiki', :web => web.address, :action => action
end
%w(file_name created_at).each do |sort_order|
expire_action :controller => 'wiki', :web => web.address, :action => 'file_list', :sort_order => sort_order
end
end
end

View file

@ -4,13 +4,18 @@ class WebSweeper < ActionController::Caching::Sweeper
include CacheSweepingHelper
observe Web, Page
observe Web, Page, WikiFile
def after_save(record)
if record.is_a?(Web)
web = record
web.pages.each { |page| expire_cached_page(web, page.name) }
expire_cached_summary_pages(web)
elsif record.is_a?(WikiFile)
record.web.pages_that_link_to(record.file_name).each do |page|
expire_cached_page(record.web, page)
end
expire_cached_summary_pages(record.web)
end
end
@ -25,9 +30,11 @@ class WebSweeper < ActionController::Caching::Sweeper
def after_destroy(record)
if record.is_a?(Web)
expire_cached_summary_pages(record)
else
elsif record.is_a?(Page)
expire_cached_page(record.web, record.name)
expire_cached_summary_pages(record.web)
else
expire_cached_summary_pages(record.web)
end
end

View file

@ -8,7 +8,7 @@ class WikiController < ApplicationController
before_filter :load_page
before_filter :dnsbl_check, :only => [:edit, :new, :save, :export_html, :export_markup]
caches_action :show, :published, :authors, :tex, :s5, :print, :recently_revised, :list,
caches_action :show, :published, :authors, :tex, :s5, :print, :recently_revised, :list, :file_list,
:atom_with_content, :atom_with_headlines, :if => Proc.new { |c| c.send(:do_caching?) }
cache_sweeper :revision_sweeper