From 6e2d11e00de49346ee6e38a1f5cd0a30e554a8e9 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Tue, 9 Dec 2008 02:20:59 -0600 Subject: [PATCH] Don't Cache Pages With Flash Messages on Them This was a long-standing annoyance. Fortunately, Rails 2.1 and later offers a way to avoid it. --- app/controllers/wiki_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 151ac27c..1350bfbb 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -7,7 +7,8 @@ require 'resolv' class WikiController < ApplicationController before_filter :load_page - caches_action :show, :published, :authors, :tex, :s5, :print, :recently_revised, :list, :atom_with_content, :atom_with_headlines + caches_action :show, :published, :authors, :tex, :s5, :print, :recently_revised, :list, + :atom_with_content, :atom_with_headlines, :if => Proc.new { |c| c.send(:do_caching?) } cache_sweeper :revision_sweeper layout 'default', :except => [:atom_with_content, :atom_with_headlines, :atom, :tex, :s5, :export_html] @@ -308,6 +309,10 @@ class WikiController < ApplicationController end protected + + def do_caching? + flash.empty? + end def load_page @page_name = params['id']