Response Caching နှင့် CDN Integration လမ်းညွှန်

Smart Money API စွမ်းဆောင်ရည်ကို ဉာဏ်ရည်တု caching ဗျူဟာများဖြင့် အကောင်းဆုံးဖြစ်အောင်လုပ်ဆောင်ပါ။ HTTP cache headers၊ ETag validation၊ CDN integration နှင့် client-side caching patterns များကို သင်ယူပြီး latency နှင့် bandwidth ကုန်ကျစရိတ်များကို လျှော့ချပါ။

မတ်လ ၂၁၊ ၂၀၂၆ တွင် ထုတ်ဝေသည် ၁၆ မိနစ် ဖတ်ရန် စွမ်းဆောင်ရည်

Caching အခြေခံအကျဉ်း

Smart Money API endpoints များသည် cryptocurrency ဈေးကွက်ဒေတာများကို အကြိမ်ကြိမ်ပြောင်းလဲနိုင်သော အကြိမ်နှုန်းများဖြင့် ဝန်ဆောင်မှုပေးသည်။ အချို့ဒေတာများ (whale addresses, funding rates) သည် စက္ကန့်အနည်းငယ်တိုင်း update ဖြစ်ပြီး အခြားဒေတာများ (historical analysis, educational content) သည် နာရီပေါင်းများစွာ မပြောင်းလဲပါ။ ဉာဏ်ရည်တု caching သည် စွမ်းဆောင်ရည်ကို သိသိသာသာ မြှင့်တင်ပေးပြီး ကုန်ကျစရိတ်များကို လျှော့ချပေးသည်။

Smart Money API သည် အဆင့်သုံးဆင့်ပါ caching ဗျူဟာကို အကောင်အထည်ဖော်ထားသည်-

  • CDN Edge Cache — အလိုအလျောက် cache invalidation ဖြင့် ကမ္ဘာလုံးဆိုင်ရာ content delivery
  • HTTP Browser Cache — standard HTTP headers များကို အသုံးပြုသော client-side caching
  • Application Cache — အကြိမ်ကြိမ်အသုံးပြုသော datasets များအတွက် in-memory caching

စွမ်းဆောင်ရည် အမြင်အာရုံ- Cached responses များသည် fresh API requests များထက် ၅၀-၁၀၀ ဆ ပိုမိုမြန်ဆန်စွာ ဝန်ဆောင်မှုပေးပြီး bandwidth ကို သိသိသာသာ သက်သာစေသည်။ သင့်လျော်စွာ cached integration သည် data transfer ကို ၇၀-၈၅% အထိ လျှော့ချနိုင်သည်။

Smart Money API response တိုင်းတွင် cache directives များ ပါဝင်ပြီး ဒေတာများ မည်မျှကြာကြာ အကျုံးဝင်သည်ကို clients နှင့် CDNs များကို ပြောပြသည်။ ဤ directives များကို နားလည်ပြီး မှန်ကန်စွာ အကောင်အထည်ဖော်ခြင်းသည် အကောင်းဆုံးစွမ်းဆောင်ရည်အတွက် အရေးကြီးသည်။

Caching ၏ အခြေခံများ

HTTP caching သည် response headers များအပေါ်တွင် အခြေခံပြီး အကြောင်းအရာကို cache လုပ်နိုင်သည်နှင့် မည်မျှကြာအောင် cache လုပ်နိုင်သည်ကို ညွှန်ပြသည်။

Cache-Control Header

cache behavior ကို ထိန်းချုပ်ရန် အဓိက mechanism။ Smart Money API response တိုင်းတွင် အောက်ပါတို့ကို ဖော်ပြသော Cache-Control header ပါဝင်သည်-

  • max-age — response သည် မည်မျှကြာကြာ အကျုံးဝင်သည်ကို စက္ကန့်ဖြင့် ဖော်ပြသည်
  • public/private — intermediate caches များက သိမ်းဆည်းနိုင်မနိုင်
  • must-revalidate — ဝန်ဆောင်မှုမပေးမီ တစ်စုံတစ်ရာ လတ်ဆတ်မှုရှိမရှိ စစ်ဆေးရန်
  • no-store — sensitive data များကို cache မလုပ်ရန်

Example Cache Headers

Endpoint အမျိုးမျိုးတွင် cache လိုအပ်ချက်များ ကွဲပြားသည်-

Response Headers
// Whale address data (၅ မိနစ်တိုင်း update ဖြစ်သည်)
Cache-Control: public, max-age=300
ETag: "abc123def456"
// Real-time funding rates (စက္ကန့်တိုင်း update ဖြစ်သည်)
Cache-Control: public, max-age=1
ETag: "xyz789abc123"
// Historical data (မပြောင်းလဲပါ)
Cache-Control: public, max-age=86400, immutable
ETag: "static-content-v1"

Cache Duration by Endpoint Type

ဒေတာအမျိုးအစား Cache Duration အသုံးပြုမှု
Real-time Funding ၁-၅ စက္ကန့် Live trading, position sizing
Whale Movements ၅ မိနစ် Signal confirmation, alerts
Daily OHLCV ၁ နာရီ Technical analysis, charts
Historical Analysis ၂၄ နာရီ Backtesting, research
Static Content ၇ ရက် API docs, guides, configuration
၃၀ စက္ကန့်အတွင်း သင့် API key ကို ရယူပါ

တည်ဆောက်ရန် အဆင်သင့်ဖြစ်ပြီလား။ အခမဲ့ API key (တစ်နေ့လျှင် ၅၀ ကြိမ်၊ ကတ်မလိုအပ်ပါ) ကို ရယူပြီး live whale၊ funding နှင့် on-chain data များကို ဆွဲယူပါ။

သင့် API key ကို ရယူပါ →

HTTP Cache Headers

Smart Money API responses များတွင် စွမ်းဆောင်ရည်ကို အမြင့်ဆုံးဖြစ်အောင် လုပ်ဆောင်ရင်း data freshness ကို ထိန်းသိမ်းရန် အတူတကွ အလုပ်လုပ်သော cache-related headers များ ပါဝင်သည်။

Cache-Control: The Primary Header

browsers နှင့် intermediate caches များအတွက် caching behavior ကို ထိန်းချုပ်သည်-

Cache-Control Directives
// Public data, ၅ မိနစ်ကြာ cache လုပ်ပါ
Cache-Control: public, max-age=300
// Private data, browser တွင်သာ cache လုပ်ပါ
Cache-Control: private, max-age=3600
// Immutable content, အမြဲတမ်း cache လုပ်ပါ
Cache-Control: public, max-age=31536000, immutable
// ဝန်ဆောင်မှုမပေးမီ အမြဲ revalidate လုပ်ပါ
Cache-Control: public, max-age=0, must-revalidate
// sensitive data များကို cache မလုပ်ပါနှင့်
Cache-Control: private, no-store, no-cache

Expires Header (Legacy)

အဟောင်း clients များအတွက်၊ Smart Money သည် Expires header (HTTP/1.0) ကိုလည်း ပံ့ပိုးပေးသည်-

Expires Header
// Absolute expiration time
Expires: Wed, 22 Mar 2026 14:30:00 GMT
// HTTP/1.1 တွင် Cache-Control max-age ကို ဦးစားပေးသည်

Last-Modified Header

အကြောင်းအရာ နောက်ဆုံးအကြိမ် update ဖြစ်သည့်အချိန်ကို ညွှန်ပြသည်၊ conditional requests များကို ဖြစ်နိုင်စေသည်-

Last-Modified Usage
// Response တွင် Last-Modified ပါဝင်သည်
Last-Modified: Wed, 21 Mar 2026 10:15:30 GMT
// Client သည် If-Modified-Since ဖြင့် revalidate လုပ်သည်
If-Modified-Since: Wed, 21 Mar 2026 10:15:30 GMT
// မပြောင်းလဲပါက server သည် 304 Not Modified ဖြင့် တုံ့ပြန်သည်
HTTP/1.1 304 Not Modified

Vary Header

caches များကို မည်သည့် request headers များက response ကို သက်ရောက်မှုရှိသည်ကို ပြောပြသည် (authentication, parameters)-

Vary Header
// Response သည် authentication နှင့် symbols အပေါ်တွင် ကွဲပြားသည်
Vary: Authorization, X-Symbols
// Caches များသည် တန်ဖိုးများကွဲပြားသော သီးခြားဗားရှင်းများကို သိမ်းဆည်းထားသည်

ETag and Conditional Requests

ETags (Entity Tags) သည် full response body ကို download မလုပ်ဘဲ cached content ကို validate လုပ်ရန် ထိရောက်သော နည်းလမ်းကို ပံ့ပိုးပေးသည်။

How ETags Work

  1. Initial Request — Client သည် data ကို တောင်းဆိုသည်၊ server သည် ETag ဖြင့် တုံ့ပြန်သည်
  2. Cache Storage — Client သည် ETag ဖြင့် response ကို cache လုပ်သည်
  3. Subsequent Request — Client သည် cached ETag နှင့် If-None-Match header ကိုပေးပို့သည်
  4. Validation — အကယ်၍ data မပြောင်းလဲပါက server သည် 304 Not Modified ကိုပြန်ပို့သည်
  5. Bandwidth Saved — response body မပို့ပါ၊ bandwidth ကိုများစွာချွေတာနိုင်သည်

ETag Implementation

Initial Request & Response
// 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...}
Conditional Revalidation
// 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

Common 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

  1. User Request — Request hits nearest Cloudflare edge location
  2. Cache Check — Edge checks if response is cached and fresh
  3. Cache Hit — If cached, serve immediately with <10ms latency
  4. Cache Miss — If not cached, fetch from origin server
  5. 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:

Manual Cache Purge
// 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:

Response Headers
// 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

JavaScript Caching
// Create cache storage
const cache = new Map();
async function fetchWithCache(url) {
// Cache ကိုအရင်စစ်ပါ
const cached = cache.get(url);
if (cached && !isCacheExpired(cached)) {
return cached.data;
}
// API မှယူပါ
const response = await fetch(url);
const data = await response.json();
// headers မှ cache duration ကိုဖတ်ပါ
const cacheControl = response.headers
get('cache-control');
const maxAge = parseMaxAge(cacheControl);
// cache ထဲသိမ်းပါ
cache.set(url, {
data,
expiry: Date.now() + (maxAge * 1000)
});
return data;
}

Service Worker Caching

Offline အတွက်ထောက်ပံ့မှုနှင့် အဆင့်မြင့် caching နည်းဗျူဟာများအတွက် Service Workers ကိုသုံးပါ-

Service Worker
// Service Worker ဖြင့် API responses များကို cache လုပ်ပါ
self.addEventListener('fetch', (event) => {
if (event.request.url.includes('api.smartmoneyapi.com')) {
// Network ကိုအရင်သုံးပါ၊ cache ကိုနောက်ဆုံးအနေနဲ့သုံးပါ
event.respondWith(
fetch(event.request)
then(response => {
// cache ကိုလတ်ဆတ်တဲ့ response နဲ့ update လုပ်ပါ
caches.open('api-cache')
then(cache => cache.put(
event.request, response.clone()));
return response;
})
catch(() =>
caches.match(event.request))
);
}
});

Cache Busting Strategies

တစ်ခါတစ်ရံ client များကို အသစ်သော data များရရှိရန် အတင်းအကျပ်လုပ်ရန် လိုအပ်ပါသည်။ ဤနည်းလမ်းများကိုသုံးပါ-

Version Parameter

data ပြောင်းလဲသောအခါ cache များကို မသုံးနိုင်အောင် version parameter တစ်ခုထည့်ပါ-

Versioned URLs
// data version သို့မဟုတ် timestamp ထည့်ပါ
https://api.smartmoneyapi.com/v1/whales/btc?v=1709980800
// data update လုပ်သောအခါ version ကိုတိုးပါ
https://api.smartmoneyapi.com/v1/whales/btc?v=1709981000
// New URL = new cache entry

Force Revalidation

Cache-Control: no-cache ကိုသုံး၍ cache ကိုအတင်းအကျပ်ပြောင်းပါ-

Force Fresh Data
// JavaScript: လတ်ဆတ်သော request ကိုအတင်းအကျပ်လုပ်ပါ
fetch(url, {
cache: 'no-cache', // အမြဲ revalidate လုပ်ပါ
headers: {
'Cache-Control': 'max-age=0'
}
});

Monitoring Cache Performance

cache hit rates နှင့် performance improvements များကိုခြေရာခံပြီး သင့် caching နည်းဗျူဟာကို အတည်ပြုပါ။

Cache Metrics to Monitor

  • Hit Rate — cache မှရရှိသော requests ရာခိုင်နှုန်း (target: >70%)
  • Response Time — ပျမ်းမျှ latency (cached: <50ms, uncached: 100-300ms)
  • Bandwidth Saved — data transfer လျှော့ချမှု
  • Origin Load — origin server တွင် request လျှော့ချမှု

Analyzing Cache Headers

Cache Analysis Script
// 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. Response Headers ကိုလေးစားပါ

Smart Money API မှ Cache-Control headers များကိုအမြဲလေးစားပါ။ no-store သို့မဟုတ် no-cache ဟုမှတ်သားထားသော content များကို cache မလုပ်ပါနှင့်။

2. Conditional Requests များကိုအကောင်အထည်ဖော်ပါ

cached content ကို revalidate လုပ်သောအခါ If-None-Match (ETag) နှင့် If-Modified-Since headers များကိုပို့ပါ။ 304 responses များဖြင့် bandwidth ကိုချွေတာပါ။

3. Data Type အလိုက် သင့်တော်စွာ cache လုပ်ပါ

  • Real-time data (funding rates): 1-5 second cache အများဆုံး
  • 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. Cache Effectiveness ကိုစောင့်ကြည့်ပါ

hit rates နှင့် latency improvements များကိုခြေရာခံပါ။ data freshness requirements နှင့် cache performance အပေါ်မူတည်၍ TTLs များကိုညှိပါ။

5. Vary Headers ကိုသတိဖြင့်သုံးပါ

Vary headers များသည် သီးခြား cache entries များဖန်တီးခြင်းဖြင့် cache hits များကိုလျှော့ချသည်။ မတူညီသော authentication levels သို့မဟုတ် parameters များအတွက်လိုအပ်မှသာသုံးပါ။

6. Multiple Layers တွင် Cache လုပ်ပါ

CDN, browser, နှင့် application levels တွင် caching ကိုအကောင်အထည်ဖော်ပါ။ origin သို့မရောက်မီ request များကို layer တစ်ခုစီကဖမ်းယူသည်။

Optimize Your API Performance

Smart Money API ၏ caching infrastructure သည် global scale တွင် sub-100ms responses များကိုသေချာစေသည်။ performance ကိုအများဆုံးဖြစ်စေရန်နှင့် costs ကိုအနည်းဆုံးဖြစ်စေရန် intelligent caching strategies များကိုအကောင်အထည်ဖော်ပါ။

Compare Plans
plan အားလုံးတွင် full CDN caching ပါဝင်သည်။ higher tiers များတွင် cache control နှင့် purging APIs များပါဝင်သည်။

Related Resources

Start free — 200 calls/day, no card

Get live whale flow, funding, open interest and on-chain data across 3 exchanges from one API. Free tier, no credit card, upgrade any time.

Start free →
Try the live API console → (no account needed)