diff --git a/packages/app/src/composables/useBitcoinPrice.ts b/packages/app/src/composables/useBitcoinPrice.ts index 039ddbcf..20c2a79c 100644 --- a/packages/app/src/composables/useBitcoinPrice.ts +++ b/packages/app/src/composables/useBitcoinPrice.ts @@ -8,7 +8,12 @@ const isLoading = ref(false) let refreshTimer: ReturnType | null = null let initialized = false +const CACHE_TTL = 30_000 // 30 seconds + async function fetchPrice() { + // Skip if we fetched recently (within TTL) + if (lastUpdated.value && Date.now() - lastUpdated.value < CACHE_TTL) return + isLoading.value = true try { const res = await fetch('https://mempool.space/api/v1/prices')