From dd5ecb9b3320d7e8294cd290728de27f408196a2 Mon Sep 17 00:00:00 2001 From: David Kinzer Date: Fri, 1 Mar 2024 13:11:15 -0500 Subject: [PATCH] Fix cached actions. Actions fail when cached using memcached because of forgery protection. Disabling the forgery proection for index actions fixes issue. Also moves cached pages to temp folder. Also removes useless expire config for cached pages. --- app/controllers/catalog_controller.rb | 3 ++- config/environments/production.rb | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index a87117aee..334619f17 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class CatalogController < ApplicationController - caches_page :show, expires_in: 24.hours + caches_page :show caches_action :index, expires_in: 12.hours, cache_path: Proc.new { |c| c.request.url } include FacetParamsDedupe @@ -13,6 +13,7 @@ class CatalogController < ApplicationController include ServerErrors include LCClassifications + skip_forgery_protection only: [:index] before_action :authenticate_purchase_order!, only: [ :purchase_order, :purchase_order_action ] before_action :set_thread_request before_action only: :index do diff --git a/config/environments/production.rb b/config/environments/production.rb index 30b8a0f94..8d6c877a4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -136,4 +136,6 @@ # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session Deprecation.default_deprecation_behavior = :silence + config.action_controller.page_cache_directory = Rails.root.join("tmp", "cached_pages") +end end