API Documentation
Response Caching and CDN Integration Guide
Optimize Smart Money API performance with intelligent caching strategies. Learn HTTP cache headers, ETag validation, CDN integration, and client-side caching patterns to reduce latency and bandwidth costs.
Published March 21, 2026
•
16 min read
•
Performance
Caching Overview
Smart Money API endpoints serve cryptocurrency market data that changes at different frequencies. Some data (whale addresses, funding rates) updates every few seconds, while other data (historical analysis, educational content) remains static for hours. Intelligent caching dramatically improves performance and reduces costs.
The Smart Money API implements a three-tier caching strategy:
- CDN Edge Cache — Global content delivery with automatic cache invalidation
- HTTP Browser Cache — Client-side caching using standard HTTP headers
- Application Cache — In-memory caching for frequently accessed datasets
Performance Insight: Cached responses serve 50-100x faster than fresh API requests and save bandwidth significantly. A properly cached integration can reduce data transfer by 70-85%.
Every Smart Money API response includes cache directives that tell clients and CDNs how long data remains valid. Understanding these directives and implementing them correctly is crucial for optimal performance.
Caching Fundamentals
HTTP caching operates based on response headers that indicate whether content can be cached and for how long.
Cache-Control Header
The primary mechanism for controlling cache behavior. Every Smart Money API response includes a Cache-Control header specifying:
- max-age — Duration in seconds the response remains valid
- public/private — Whether intermediate caches can store it
- must-revalidate — Whether to check freshness before serving
- no-store — Don't cache sensitive data
Example Cache Headers
Different endpoints have different cache requirements:
// Whale address data (updates every 5 minutes)
Cache-Control: public, max-age=300
ETag: "abc123def456"
// Real-time funding rates (updates every second)
Cache-Control: public, max-age=1
ETag: "xyz789abc123"
// Historical data (doesn't change)
Cache-Control: public, max-age=86400, immutable
ETag: "static-content-v1"
Cache Duration by Endpoint Type
| Data Type |
Cache Duration |
Use Case |
| Real-time Funding |
1-5 seconds |
Live trading, position sizing |
| Whale Movements |
5 minutes |
Signal confirmation, alerts |
| Daily OHLCV |
1 hour |
Technical analysis, charts |
| Historical Analysis |
24 hours |
Backtesting, research |
| Static Content |
7 days |
API docs, guides, configuration |
Get your API key in 30 seconds
Ready to build? Grab a free API key (200 calls/day, no card) and start pulling live whale, funding and on-chain data.
Get your API key →
ETag and Conditional Requests
ETags (Entity Tags) provide an efficient way to validate cached content without downloading the full response body.
How ETags Work
- Initial Request — Client requests data, server responds with ETag
- Cache Storage — Client caches response with ETag
- Subsequent Request — Client sends If-None-Match header with cached ETag
- Validation — If data unchanged, server returns 304 Not Modified
- Bandwidth Saved — No response body sent, huge bandwidth savings
ETag Implementation
// First request
GET /v1/whales/btc HTTP/1.1
// Response includes ETag
HTTP/1.1 200 OK
ETag: "8a3b9c2d"
Cache-Control: public, max-age=300
Content-Type: application/json
{...response body...}
// After cache expires, send If-None-Match
GET /v1/whales/btc HTTP/1.1
If-None-Match: "8a3b9c2d"
// If unchanged, server responds 304
HTTP/1.1 304 Not Modified
ETag: "8a3b9c2d"
Cache-Control: public, max-age=300
// No body sent! Bandwidth saved
ETag Strength
ETags can be strong or weak:
| Type |
Format |
Use Case |
| Strong ETag |
"8a3b9c2d" |
Byte-for-byte identical, use for validation |
| Weak ETag |
W/"8a3b9c2d" |
Semantically equivalent, for display changes |
Cache Control Directives
Understanding Cache-Control directives enables building optimal caching strategies for your application.
Directive Reference
| Directive |
Meaning |
Example |
| max-age |
Seconds response remains fresh |
max-age=300 |
| public |
Cache can store and share |
public |
| private |
Cache for recipient only |
private |
| must-revalidate |
Revalidate when stale |
must-revalidate |
| no-cache |
Must revalidate before use |
no-cache |
| no-store |
Don't cache at all |
no-store |
| immutable |
Never changes, cache forever |
immutable |
| s-maxage |
CDN cache duration |
s-maxage=3600 |
Practical Cache-Control Patterns
// Pattern 1: Browser cache, CDN for 1 hour
Cache-Control: public, max-age=300, s-maxage=3600
// Pattern 2: Per-user data, no proxy cache
Cache-Control: private, max-age=1800
// Pattern 3: Always fresh, always check
Cache-Control: public, no-cache, must-revalidate
// Pattern 4: Immutable versioned asset
Cache-Control: public, max-age=31536000, immutable
CDN Integration
Smart Money API delivers responses through Cloudflare's global CDN network, automatically caching responses at edge locations worldwide for minimal latency.
How Smart Money CDN Works
- User Request — Request hits nearest Cloudflare edge location
- Cache Check — Edge checks if response is cached and fresh
- Cache Hit — If cached, serve immediately with <10ms latency
- Cache Miss — If not cached, fetch from origin server
- Store and Serve — Cache response and deliver to user
Cache Key Configuration
Cloudflare uses cache keys to uniquely identify cached responses. By default:
- Request path and query parameters are included
- Most headers are ignored (to maximize cache hits)
- Authorization headers are NOT included (no account leakage)
- Custom headers can be included via Vary header
CDN Purging
Smart Money automatically purges CDN cache when data updates:
// Purge specific URL from CDN
curl -X POST "https://api.smartmoneyapi.com/v1/cache/purge" \
-H "Authorization: Bearer token" \
-d '{
"urls": [
"https://api.smartmoneyapi.com/v1/whales/btc"
]
}'
Measuring CDN Performance
Check response headers to see if request was served from cache:
// Cache hit from CDN edge
CF-Cache-Status: HIT
CF-RAY: 8a9b7c6d5e4f3g2h
Age: 45 // seconds since cached
// Cache miss, fetched from origin
CF-Cache-Status: MISS
Age: 0
Client-Side Caching
Implement caching in your application to further reduce API calls and improve responsiveness.
Browser Cache Implementation
// Create cache storage
const cache = new Map();
async function fetchWithCache(url) {
// Check cache first
const cached = cache.get(url);
if (cached && !isCacheExpired(cached)) {
return cached.data;
}
// Fetch from API
const response = await fetch(url);
const data = await response.json();
// Parse cache duration from headers
const cacheControl = response.headers
.get('cache-control');
const maxAge = parseMaxAge(cacheControl);
// Store in cache
cache.set(url, {
data,
expiry: Date.now() + (maxAge * 1000)
});
return data;
}
Service Worker Caching
For offline support and advanced caching strategies, use Service Workers:
// Cache API responses with Service Worker
self.addEventListener('fetch', (event) => {
if (event.request.url.includes('api.smartmoneyapi.com')) {
// Network first, fall back to cache
event.respondWith(
fetch(event.request)
.then(response => {
// Update cache with fresh response
caches.open('api-cache')
.then(cache => cache.put(
event.request, response.clone()));
return response;
})
.catch(() =>
caches.match(event.request))
);
}
});
Cache Busting Strategies
Sometimes you need to force clients to get fresh data. Use these techniques:
Version Parameter
Add a version parameter to invalidate caches when data changes:
// Include data version or timestamp
https://api.smartmoneyapi.com/v1/whales/btc?v=1709980800
// When data updates, increment version
https://api.smartmoneyapi.com/v1/whales/btc?v=1709981000
// New URL = new cache entry
Force Revalidation
Override cache with Cache-Control: no-cache when you need fresh data:
// JavaScript: Force fresh request
fetch(url, {
cache: 'no-cache', // Revalidate always
headers: {
'Cache-Control': 'max-age=0'
}
});
Monitoring Cache Performance
Track cache hit rates and performance improvements to validate your caching strategy.
Cache Metrics to Monitor
- Hit Rate — Percentage of requests served from cache (target: >70%)
- Response Time — Average latency (cached: <50ms, uncached: 100-300ms)
- Bandwidth Saved — Reduction in data transfer
- Origin Load — Request reduction at origin server
Analyzing Cache Headers
// Analyze response cache headers
async function analyzeCache(url) {
const response = await fetch(url);
return {
cacheControl: response.headers
.get('cache-control'),
etag: response.headers.get('etag'),
age: response.headers.get('age'),
cfStatus: response.headers
.get('cf-cache-status'),
contentLength:
response.headers.get('content-length')
};
}
Caching Best Practices
1. Respect Response Headers
Always respect Cache-Control headers from Smart Money API. Don't cache content marked no-store or no-cache.
2. Implement Conditional Requests
Send If-None-Match (ETag) and If-Modified-Since headers when revalidating cached content. Save bandwidth with 304 responses.
3. Cache Appropriately by Data Type
- Real-time data (funding rates): 1-5 second cache maximum
- Live signals (whale movement): 5-30 second cache
- Hourly data (OHLCV): 1 hour cache
- Historical data: 24-hour cache
- Static content: 7-day cache
4. Monitor Cache Effectiveness
Track hit rates and latency improvements. Adjust TTLs based on data freshness requirements and cache performance.
5. Use Vary Headers Carefully
Vary headers reduce cache hits by creating separate cache entries. Only use when necessary for different authentication levels or parameters.
6. Cache at Multiple Layers
Implement caching at CDN, browser, and application levels. Each layer catches requests before hitting origin.
Optimize Your API Performance
Smart Money API's caching infrastructure ensures sub-100ms responses at global scale. Implement intelligent caching strategies to maximize performance and minimize costs.
Compare Plans
All plans include full CDN caching. Higher tiers provide cache control and purging APIs.