Cache-Control Headers
Olympus responses include Cache-Control headers indicating recommended caching durations for each endpoint.
Olympus responses include Cache-Control headers indicating recommended caching durations for each endpoint.
Different data types require different TTLs. Entity status: 24h. License checks: 6h. Tax rates: 24h. Demographics: 30d. SEC filings: 1h for recent, indefinite for historical.
Implement caching at multiple layers: CDN for public data, application cache for authenticated data, database for persistent storage.
class="text-pink-400">import { Redis } class="text-pink-400">from class="text-emerald-class="text-amber-400">400">'ioredis';
class="text-pink-400">const redis = class="text-pink-400">new Redis();
class="text-pink-400">const TTL = {
entityStatus: class="text-amber-400">86400, class="text-white/class="text-amber-400">30 italic">// class="text-amber-400">24 hours
licenseCheck: class="text-amber-400">21600, class="text-white/class="text-amber-400">30 italic">// class="text-amber-400">6 hours
taxRates: class="text-amber-400">86400, class="text-white/class="text-amber-400">30 italic">// class="text-amber-400">24 hours
demographics: class="text-amber-400">2592000, class="text-white/class="text-amber-400">30 italic">// class="text-amber-400">30 days
};
class="text-pink-400">async class="text-pink-400">function getCached<T>(
key: string,
fetcher: () => Promise<T>,
ttl: number
): Promise<T> {
class="text-pink-400">const cached = class="text-pink-400">await redis.get(key);
class="text-pink-400">if (cached) class="text-pink-400">return JSON.parse(cached);
class="text-pink-400">const data = class="text-pink-400">await fetcher();
class="text-pink-400">await redis.setex(key, ttl, JSON.stringify(data));
class="text-pink-400">return data;
}Use webhooks to invalidate cached data when entities change, ensuring your cache stays accurate.
Explore our API documentation to start building with Olympus.