Cache file_list Action
Also, slightly smarter cache expiry, upon uploading/deleting a file.
This commit is contained in:
parent
5c20871ec4
commit
b9f5c32755
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<a href="<%= url_for :web => @web.address, :action => 'files',
|
||||
:id => file.file_name %>"><%= file.file_name%></a> (<%= file.created_at.asctime %>) <span class="linked"><%= "Linked to by: " unless
|
||||
@web.pages_that_link_to(file.file_name).empty? -%>
|
||||
<%= @web.pages_that_link_to(file.file_name).collect { |referring_page| link_to referring_page }.join(", ") %></span>
|
||||
<%= @web.pages_that_link_to(file.file_name).collect { |referring_page| link_to_page(referring_page) }.join(", ") %></span>
|
||||
</li>
|
||||
<%- end -%>
|
||||
</ul>
|
||||
|
|
|
@ -20,6 +20,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
connect_to_web map, ':web/remove_orphaned_pages_in_category', :controller => 'admin', :action => 'remove_orphaned_pages_in_category'
|
||||
connect_to_web map, ':web/file/delete/:id', :controller => 'file', :action => 'delete', :requirements => {:id => /[-._\w]+/}, :id => nil
|
||||
connect_to_web map, ':web/files/:id', :controller => 'file', :action => 'file', :requirements => {:id => /[-._\w]+/}, :id => nil
|
||||
connect_to_web map, ':web/file_list/:sort_order', :controller => 'wiki', :action => 'file_list', :sort_order => nil
|
||||
connect_to_web map, ':web/import/:id', :controller => 'file', :action => 'import'
|
||||
connect_to_web map, ':web/login', :controller => 'wiki', :action => 'login'
|
||||
connect_to_web map, ':web/web_list', :controller => 'wiki', :action => 'web_list'
|
||||
|
|
Loading…
Reference in a new issue