The 10 most important things to prepare about caching if you are appearing in a software engineer interview, especially backend are the following.
What can be cached —Client, Server, In Between (Server-Database ), API, Hardware (CPU). Operations that are used frequently, heavy operation/computation;
Cache— Hardware or software that stores the data to provide faster access (the result of the heavy computation, API responses, API requests);
Write through cache— when the cache is updated in cache and memory synchronously, recover data if the process dies. Pros — simpler and reliable; cons — better works when not so many writes in cache;
CacheHit— find requested data in the cache
Cache miss— did not find stored cache because of pure design
Cache eviction policy— rules when cached will be removed (LRU(recent),LFU(frequent),FIFO(queue))
Content Delivery Network(CDN)— third party service that caches your server (based on region), always better latency. PoP (Point of Presence).Cloudflare, Google Cloud CDN.
Write back cache— when cache updated in cache and memory asynchronously;
If we care of the staleness of cache (accuracy of data) -> we use local cache;if accuracy is important (views, likes)— use third party cache (Redis)
Golden Rule: Not every time, when optimizations are needed to be done and caching is the perfect solution.