From a07780ab61e2cf1a8d304d1250a80cf7826ac762 Mon Sep 17 00:00:00 2001 From: Daniel <80175477+dan437@users.noreply.github.com> Date: Fri, 9 Apr 2021 17:59:52 -0700 Subject: [PATCH] Change caching for Swaps APIs from 1 hour to 5 minutes (#10871) * Change caching for the /tokens API from 1 hour to 5 minutes * Use 5 minutes caching for /topAssets and /aggregatorMetadata APIs as well --- ui/app/pages/swaps/swaps.util.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/app/pages/swaps/swaps.util.js b/ui/app/pages/swaps/swaps.util.js index e97a751ae..8606ea8d3 100644 --- a/ui/app/pages/swaps/swaps.util.js +++ b/ui/app/pages/swaps/swaps.util.js @@ -34,7 +34,7 @@ import { calcGasTotal } from '../send/send.utils'; const TOKEN_TRANSFER_LOG_TOPIC_HASH = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'; -const CACHE_REFRESH_ONE_HOUR = 3600000; +const CACHE_REFRESH_FIVE_MINUTES = 300000; const getBaseApi = function (type, chainId = MAINNET_CHAIN_ID) { switch (type) { @@ -290,7 +290,7 @@ export async function fetchTokens(chainId) { const tokens = await fetchWithCache( tokenUrl, { method: 'GET' }, - { cacheRefreshTime: CACHE_REFRESH_ONE_HOUR }, + { cacheRefreshTime: CACHE_REFRESH_FIVE_MINUTES }, ); const filteredTokens = [ SWAPS_CHAINID_DEFAULT_TOKEN_MAP[chainId], @@ -312,7 +312,7 @@ export async function fetchAggregatorMetadata(chainId) { const aggregators = await fetchWithCache( aggregatorMetadataUrl, { method: 'GET' }, - { cacheRefreshTime: CACHE_REFRESH_ONE_HOUR }, + { cacheRefreshTime: CACHE_REFRESH_FIVE_MINUTES }, ); const filteredAggregators = {}; for (const aggKey in aggregators) { @@ -334,7 +334,7 @@ export async function fetchTopAssets(chainId) { const response = await fetchWithCache( topAssetsUrl, { method: 'GET' }, - { cacheRefreshTime: CACHE_REFRESH_ONE_HOUR }, + { cacheRefreshTime: CACHE_REFRESH_FIVE_MINUTES }, ); const topAssetsMap = response.reduce((_topAssetsMap, asset, index) => { if (validateData(TOP_ASSET_VALIDATORS, asset, topAssetsUrl)) {