diff --git a/app/jobs/cache/browser_channels/main.rb b/app/jobs/cache/browser_channels/main.rb index c6c0caa0a9..6a5205eafa 100644 --- a/app/jobs/cache/browser_channels/main.rb +++ b/app/jobs/cache/browser_channels/main.rb @@ -18,6 +18,10 @@ def perform else Time.at(0).to_s end + + # Warm the cache to avoid 429/ thundering stampede + Rewards::Parameters.new.fetch_allowed_regions + if full_refresh_not_ran_recently?(all_prefixes_run_time: all_prefixes_run_time) && queue_depth_small? run_all_prefixes Rails.cache.write(LAST_RAN_ALL_KEY, Time.now.to_s) diff --git a/lib/rewards/parameters.rb b/lib/rewards/parameters.rb index 85de2d039b..5152a4a137 100644 --- a/lib/rewards/parameters.rb +++ b/lib/rewards/parameters.rb @@ -11,7 +11,7 @@ def get_parameters end def get_cached_parameters - Rails.cache.fetch(RATES_CACHE_KEY, expires_in: 5.minutes) do + Rails.cache.fetch(RATES_CACHE_KEY, expires_in: 1.hour) do get_parameters end end