Skip to content

Commit

Permalink
do some caching to reduce the number of solr queries for categories
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgrove73 committed Nov 13, 2017
1 parent 84fef98 commit ddde8b7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 3 additions & 1 deletion app/views/catalog/_home_text.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

<% #exhibits.each_slice(3).each do |row| %>
<div class="row"><!-- start main content row -->
<%= render partial: 'edition_card' %>
<% cache('edition-cards', expires_in: 1.hour) do %>
<%= render partial: 'edition_card' %>
<% end %>
</div>
<% #end %>

Expand Down
8 changes: 6 additions & 2 deletions app/views/tree/_show_tree.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ different format for the facets (I think it's bug in Blacklight)-->

<% if subject_id %>
<!--Show the tree -->
<%= render :partial => 'tree/tree', locals: {:subject_id => subject_id, :lang => lang, :filter_params_url => filter_params_url} %>
<% cache(subject_id.gsub('/','#'), expires_in: 1.hour) do %>
<%= render :partial => 'tree/tree', locals: {:subject_id => subject_id, :lang => lang, :filter_params_url => filter_params_url} %>
<% end %>
<% else %>
<%= render :partial => 'tree/tree', locals: {:subject_id => "/editions/any/2009/jul/editions", :lang => lang, :filter_params_url => filter_params_url} %>
<% cache('subject-all', expires_in: 1.hour) do %>
<%= render :partial => 'tree/tree', locals: {:subject_id => "/editions/any/2009/jul/editions", :lang => lang, :filter_params_url => filter_params_url} %>
<% end %>
<% end %>
16 changes: 3 additions & 13 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,9 @@
# Show full error reports.
config.consider_all_requests_local = true

# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true

config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
}
else
config.action_controller.perform_caching = false

config.cache_store = :null_store
end
#cache settings
config.action_controller.perform_caching = true
config.cache_store = :memory_store, { size: 64.megabytes }

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
Expand Down
6 changes: 6 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false

#cache settings
config.action_controller.perform_caching = true
config.cache_store = :memory_store, {size: 64.megabytes}
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
}

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
Expand Down

0 comments on commit ddde8b7

Please sign in to comment.