aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/helpers/application_helper.rb7
-rw-r--r--app/views/general/frontpage.html.erb2
-rw-r--r--app/views/request/_sidebar.html.erb2
-rw-r--r--config/general.yml-example5
-rw-r--r--lib/configuration.rb1
5 files changed, 15 insertions, 2 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e3b1e57ac..0c346ab4e 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -116,5 +116,12 @@ module ApplicationHelper
return !session[:using_admin].nil? || (!@user.nil? && @user.super?)
end
+ def cache_if_caching_fragments(*args, &block)
+ if AlaveteliConfiguration::cache_fragments
+ cache(*args) { yield }
+ else
+ yield
+ end
+ end
end
diff --git a/app/views/general/frontpage.html.erb b/app/views/general/frontpage.html.erb
index 2900782ef..8bb32bdf2 100644
--- a/app/views/general/frontpage.html.erb
+++ b/app/views/general/frontpage.html.erb
@@ -1,4 +1,4 @@
-<% cache("frontpage-#{@locale}", :expires_in => 5.minutes) do %>
+<% cache_if_caching_fragments("frontpage-#{@locale}", :expires_in => 5.minutes) do %>
<div id="frontpage_splash">
<div id="left_column">
<%= render :partial => "frontpage_new_request" %>
diff --git a/app/views/request/_sidebar.html.erb b/app/views/request/_sidebar.html.erb
index 71405ae06..8400cd6ac 100644
--- a/app/views/request/_sidebar.html.erb
+++ b/app/views/request/_sidebar.html.erb
@@ -51,7 +51,7 @@
<%= render :partial => 'request/next_actions' %>
- <% cache(@similar_cache_key, :expires_in => 1.day) do %>
+ <% cache_if_caching_fragments(@similar_cache_key, :expires_in => 1.day) do %>
<% xapian_similar, xapian_similar_more = @info_request.similar_requests %>
<% if !xapian_similar.nil? && xapian_similar.results.size > 0 %>
<h2><%= _('Similar requests')%></h2>
diff --git a/config/general.yml-example b/config/general.yml-example
index 60eb5ae1c..b8d9fc854 100644
--- a/config/general.yml-example
+++ b/config/general.yml-example
@@ -209,3 +209,8 @@ PUBLIC_BODY_LIST_FALLBACK_TO_DEFAULT_LOCALE: false
# If true, while in development mode, try to send mail by SMTP to port
# 1025 (the port the mailcatcher listens on by default):
USE_MAILCATCHER_IN_DEVELOPMENT: true
+
+# Use memcached to cache HTML fragments for better performance. Will
+# only have an effect in environments where
+# config.action_controller.perform_caching is set to true
+CACHE_FRAGMENTS: true
diff --git a/lib/configuration.rb b/lib/configuration.rb
index fba70f27c..2192433f7 100644
--- a/lib/configuration.rb
+++ b/lib/configuration.rb
@@ -21,6 +21,7 @@ module AlaveteliConfiguration
:AVAILABLE_LOCALES => '',
:BLACKHOLE_PREFIX => 'do-not-reply-to-this-address',
:BLOG_FEED => '',
+ :CACHE_FRAGMENTS => true,
:CONTACT_EMAIL => 'contact@localhost',
:CONTACT_NAME => 'Alaveteli',
:COOKIE_STORE_SESSION_SECRET => 'this default is insecure as code is open source, please override for live sites in config/general; this will do for local development',