Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change site.config.cache_enable to a callback

  • Loading branch information...
commit 446ec048144ba4819dde2f057e36c1e108ba56b6 1 parent ce0d9a2
@aceofspades authored
View
2  README.md
@@ -81,7 +81,7 @@ Caloris.configure do |config|
config.root = File.expand_path('cms_content', Rails.root)
end
config.default_page_template = 'plain'
- config.cache_enable = Rails.env.production?
+ config.cache_enable = proc { |controller, page| Rails.env.production? }
config.metadata_schema = {
page_information: {
page_id: :string,
View
2  app/controllers/caloris/pages_controller.rb
@@ -156,7 +156,7 @@ def maybe_cached_render(page)
block = proc do |page|
render_to_string inline: page.render, layout: false
end
- if page.cache_enable
+ if page.cache_enable && page.site.cache_enable(self, page)
key = ActionCachePath.new(self, params).path
if params[:expire_cache]
View
2  app/models/caloris/page.rb
@@ -78,7 +78,7 @@ def body
# @returns [Boolean] true if page should be cached
def cache_enable
- metadata['cache_enable'] == 'true' || @site.cache_enable
+ metadata['cache_enable'] != 'false'
end
# @returns [Integer] number of seconds to cache page
View
6 app/models/caloris/site.rb
@@ -52,7 +52,7 @@ def initialize site, &block
@formats = %w(html html.erb)
@storage = {git: {branch: 'master'}}
- @cache_enable = false
+ @cache_enable = proc { |controller, page| false }
@cache_expiration = 5.minutes
@cache_public = true
@@ -282,6 +282,10 @@ def metadatum_type key
flattened_metadata_schema[key]
end
+ def cache_enable controller, page
+ config.cache_enable.call(controller, page)
+ end
+
private
def asset_directories
Please sign in to comment.
Something went wrong with that request. Please try again.