Caching จัดเก็บข้อมูลที่ถูกเข้าถึงบ่อยไว้ในเลเยอร์ที่รวดเร็ว (มักอยู่ในหน่วยความจำ) เพื่อให้สามารถดึงข้อมูลได้อย่างรวดเร็วโดยไม่ต้องคำนวณใหม่หรือดึงจากแหล่งที่ช้ากว่าอีกครั้ง มันเป็นหนึ่งในเทคนิคที่สำคัญที่สุดสำหรับการปรับปรุง performance และ scalability
Caching ทำอะไร
CACHING stores copies of data in a FAST location for quick repeated access:
→ instead of recomputing or re-fetching from a slow source (database, API, computation),
serve from the fast cache
→ DRAMATICALLY faster (cache hit) + REDUCES load on the slow backend
→ trades some staleness/complexity for big performance and scalability gains.
Caching ถูกใช้ที่ไหนบ้าง (เลเยอร์ต่าง ๆ)
BROWSER / CLIENT cache → cache on the user's device
CDN → cache static content at edge locations near users
APPLICATION cache (e.g. Redis/Memcached) → cache DB query results, computed data, sessions
DATABASE cache → query/result caching
→ caching can happen at MULTIPLE layers (defense in depth for performance)
