diff --git a/app/controllers/api/order_cycles_controller.rb b/app/controllers/api/order_cycles_controller.rb index 0ac5223ea1..e2bca5a626 100644 --- a/app/controllers/api/order_cycles_controller.rb +++ b/app/controllers/api/order_cycles_controller.rb @@ -1,10 +1,12 @@ module Api class OrderCyclesController < Api::BaseController include EnterprisesHelper - respond_to :json + include ApiActionCaching skip_authorization_check + caches_action :taxons, :properties, expires_in: CacheService::FILTERS_EXPIRY + def products products = ProductsRenderer.new( distributor, diff --git a/app/services/cache_service.rb b/app/services/cache_service.rb index 4a87dcea9a..610b4ca6b4 100644 --- a/app/services/cache_service.rb +++ b/app/services/cache_service.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class CacheService + FILTERS_EXPIRY = 30.seconds.freeze + def self.cache(cache_key, options = {}) Rails.cache.fetch cache_key.to_s, options do yield