Skip to content

Commit

Permalink
Do not cache the essence view partials
Browse files Browse the repository at this point in the history
Caching the essence view partials does not make any sense, when the element is already cached. The essence views has no complex computation or DB queries, but lots of moving parts (`html_options`, `options`).

Caching them is more harmful then helpful.
  • Loading branch information
Thomas von Deyen committed Aug 4, 2016
1 parent 599ea92 commit 4bb35cf
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 3.5.0 (unreleased)

__Notable Changes__

* The essence view partials don't get cached anymore (#1099)

## 3.4.0 (2016-08-02)

__New Features__
Expand Down
4 changes: 1 addition & 3 deletions app/views/alchemy/essences/_essence_boolean_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<%- cache(content) do -%>
<%= Alchemy.t(content.ingredient) -%>
<%- end -%>
<%= Alchemy.t(content.ingredient) -%>
2 changes: 0 additions & 2 deletions app/views/alchemy/essences/_essence_date_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<%- cache(content) do -%>
<%- date_format = content.settings_value(:date_format,
local_assigns.fetch(:options, {})) -%>
<%- if content.ingredient.present? -%>
Expand All @@ -7,5 +6,4 @@
<%- else -%>
<%= l(content.ingredient, format: date_format) %>
<%- end -%>
<%- end -%>
<%- end -%>
4 changes: 1 addition & 3 deletions app/views/alchemy/essences/_essence_file_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<%- cache(content) do -%>
<%- if attachment = content.ingredient -%>
<%= link_to(
content.essence.link_text.presence ||
Expand All @@ -12,5 +11,4 @@
class: content.essence.css_class.presence,
title: content.essence.title.presence
) -%>
<%- end -%>
<%- end -%>
<%- end -%>
4 changes: 1 addition & 3 deletions app/views/alchemy/essences/_essence_html_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<% cache(content) do %>
<%= raw content.ingredient -%>
<% end %>
<%= raw content.ingredient -%>
2 changes: 0 additions & 2 deletions app/views/alchemy/essences/_essence_link_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<%- cache(content) do -%>
<%- if content.ingredient.present? -%>
<%- html_options = {
target: content.essence.link_target == "blank" ? "_blank" : nil
Expand All @@ -7,5 +6,4 @@
<%= content.settings_value(:text, local_assigns.fetch(:options, {})) ||
content.ingredient -%>
<%- end -%>
<%- end -%>
<%- end -%>
4 changes: 1 addition & 3 deletions app/views/alchemy/essences/_essence_picture_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<% cache(content) do %>
<%= Alchemy::EssencePictureView.new(
content,
local_assigns[:options],
local_assigns[:html_options]
).render %>
<% end %>
).render %>
4 changes: 1 addition & 3 deletions app/views/alchemy/essences/_essence_richtext_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<%- cache(content) do -%>
<%- options = local_assigns.fetch(:options, {}) -%>
<%- plain_text = !!content.settings_value(:plain_text, options) -%>
<%= raw content.essence.send(plain_text ? :stripped_body : :body) -%>
<%- end -%>
<%= raw content.essence.public_send(plain_text ? :stripped_body : :body) -%>
4 changes: 1 addition & 3 deletions app/views/alchemy/essences/_essence_select_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<% cache(content) do %>
<%= content.ingredient %>
<% end %>
<%= content.ingredient %>
2 changes: 0 additions & 2 deletions app/views/alchemy/essences/_essence_text_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<%- cache(content) do -%>
<%- options = local_assigns.fetch(:options, {}) -%>
<%- html_options = local_assigns.fetch(:html_options, {}) -%>
<%- if content.essence.link.blank? ||
Expand All @@ -14,5 +13,4 @@
'data-link-target' => content.essence.link_target
}.merge(html_options)
) -%>
<%- end -%>
<%- end -%>

0 comments on commit 4bb35cf

Please sign in to comment.