Files
worldmonitor/server/_shared/cache-keys.ts
Elie Habib 2e93e0e8ed perf(bootstrap): tier slow/fast data for ~46% CDN egress reduction (#838)
Split bootstrap endpoint into slow-changing (1h TTL: BIS rates,
minerals, sectors, etc.) and fast-changing (10min TTL: earthquakes,
outages, macro signals, etc.) tiers via ?tier=slow|fast query param.

Frontend fetches both tiers in parallel with shared 800ms timeout.
Partial failure is graceful — panels fall through to individual RPCs.
Backward compatible: no ?tier= param returns all keys at s-maxage=600.

Also removes orphaned ucdpEvents key (no getHydratedData consumer).
2026-03-03 01:33:01 +04:00

31 lines
1.2 KiB
TypeScript

/**
* Static cache keys for the bootstrap endpoint.
* Only keys with NO request-varying suffixes are included.
*/
export const BOOTSTRAP_CACHE_KEYS: Record<string, string> = {
earthquakes: 'seismology:earthquakes:v1',
outages: 'infra:outages:v1',
serviceStatuses: 'infra:service-statuses:v1',
sectors: 'market:sectors:v1',
etfFlows: 'market:etf-flows:v1',
macroSignals: 'economic:macro-signals:v1',
bisPolicy: 'economic:bis:policy:v1',
bisExchange: 'economic:bis:eer:v1',
bisCredit: 'economic:bis:credit:v1',
shippingRates: 'supply_chain:shipping:v2',
chokepoints: 'supply_chain:chokepoints:v1',
minerals: 'supply_chain:minerals:v1',
giving: 'giving:summary:v1',
climateAnomalies: 'climate:anomalies:v1',
wildfires: 'wildfire:fires:v1',
};
export const BOOTSTRAP_TIERS: Record<string, 'slow' | 'fast'> = {
bisPolicy: 'slow', bisExchange: 'slow', bisCredit: 'slow',
minerals: 'slow', giving: 'slow', sectors: 'slow',
etfFlows: 'slow', shippingRates: 'slow', wildfires: 'slow',
climateAnomalies: 'slow',
earthquakes: 'fast', outages: 'fast', serviceStatuses: 'fast',
macroSignals: 'fast', chokepoints: 'fast',
};