Skip to main content

Data Freshness

Understanding how often data updates helps you build better applications.

Cache TTL by Data Type

Data TypeCache TTLUpdate FrequencyNotes
Token Prices30 secondsReal-timeFrom CoinGecko/DefiLlama
Gas Prices15 secondsPer block~12s on Ethereum
ENS Resolution5 minutesOn-chain eventsCached after first lookup
ENS Profiles1 hourRare changesAvatar, bio, records
Farcaster Profiles5 minutesUser updatesFollower counts may lag
Farcaster Feeds2 minutesContinuousNew casts every few seconds
Farcaster Channels10 minutesVariableChannel stats
DeFi TVL5 minutesHourly+From DefiLlama
Protocol Yields15 minutesVariableAPY calculations
Staking Data10 minutesVariableValidator stats
Wallet Balances1 minutePer blockMay lag during congestion
Token Holdings2 minutesPer blockERC-20 balances
NFT Holdings5 minutesOn transferOwnership changes
NFT Metadata24 hoursRare changesIPFS content immutable
Security Scans30 minutesOn-demandToken contract analysis
Fear & Greed Index1 hourDaily updateSentiment indicator
Historical DataIndefiniteNeverPast data is immutable

Response Headers

Every response includes cache information:

X-Cache-TTL: 30
X-Cache-Hit: true
X-Data-Timestamp: 2026-02-08T12:00:00Z
HeaderDescription
X-Cache-TTLSeconds until data is considered stale
X-Cache-HitWhether response came from cache
X-Data-TimestampWhen the data was last fetched from source

Freshness Guarantees

Real-Time Data (< 1 minute)

Best for: Trading apps, gas estimation, price alerts

# Token prices - 30s cache
curl https://api.web3identity.com/api/price/eth

# Gas prices - 15s cache
curl https://api.web3identity.com/api/gas

Near Real-Time (1-5 minutes)

Best for: Wallet apps, social features, dashboards

# Wallet balances - 1m cache
curl https://api.web3identity.com/api/wallet/0x.../balances

# ENS resolution - 5m cache
curl https://api.web3identity.com/api/ens/resolve/vitalik.eth

Periodic Updates (5-60 minutes)

Best for: Analytics, leaderboards, aggregate stats

# DeFi TVL - 5m cache
curl https://api.web3identity.com/api/defi/tvl

# Protocol yields - 15m cache
curl https://api.web3identity.com/api/yields

Static Data (hours to days)

Best for: Profile pages, NFT displays, historical analysis

# ENS full profile - 1h cache
curl https://api.web3identity.com/api/ens/profile/vitalik.eth

# NFT metadata - 24h cache
curl https://api.web3identity.com/api/nft/0x.../1

Force Fresh Data

For critical operations, you can bypass the cache:

curl -H "Cache-Control: no-cache" \
https://api.web3identity.com/api/price/eth
Rate Limit Impact

Cache bypass requests count against your rate limit. Use sparingly.

Best Practices

Match TTL to Use Case

// ✅ Good: Cache matches data volatility
const priceCache = new Map(); // 30s TTL
const profileCache = new Map(); // 1h TTL

// ❌ Bad: Same cache for everything
const cache = new Map(); // 5m TTL for all

Stale-While-Revalidate

Serve cached data immediately, refresh in background:

async function getPrice(token) {
const cached = priceCache.get(token);
const now = Date.now();

// Fresh enough - return immediately
if (cached && now - cached.time < 30000) {
return cached.data;
}

// Stale but usable - return and refresh
if (cached && now - cached.time < 60000) {
refreshPrice(token); // Background refresh
return cached.data;
}

// Too stale - must wait for fresh data
return await fetchPrice(token);
}

Handle Stale Data Gracefully

const data = await api.getPrice('eth');
const age = Date.now() - new Date(data.timestamp).getTime();

if (age > 60000) {
// Data is over 1 minute old
showWarning('Price may be outdated');
}

Data Source Latency

Different sources have different update frequencies:

SourceTypical LatencyNotes
Direct RPC1-2 blocksMost accurate
The Graph1-5 minutesIndexed data
CoinGecko30-60 secondsPrice aggregation
DefiLlama5-15 minutesTVL calculations
Neynar (Farcaster)Near real-timeSocial data

Monitoring Freshness

Check data source health:

curl https://api.web3identity.com/api/sources/health
{
"sources": {
"coingecko": { "status": "healthy", "lastUpdate": "2026-02-08T12:00:00Z" },
"defillama": { "status": "healthy", "lastUpdate": "2026-02-08T11:55:00Z" },
"neynar": { "status": "healthy", "lastUpdate": "2026-02-08T12:00:05Z" }
}
}