system-design-refresher

Caching and CDN

CDN Caching
Reduced Latency Reduced Latency
High Availability Lowered Server Load
Improved Security Improved UI

Contents

Caching

Technique used to improve the performance and efficiency of a system. It involves storing a copy of data in a temporary storage (cache) so that future requests for that data can be serverd faster.

Browser Caching

Server Caching

alt text

Eviction Policies

What happens if the cache is full ? We need to set rules to remove from the cache when it is full. Common used policies are:

Database Caching

Usually done by the database internally or by an external cache layer like Redis or Memcached

alt text

Content Delivery Networks (CDN)

Generally used to serve static content like HTML, JS, CSS and media files. They cache the content from the original server and deliver it to users from the neares CDN server. If the CDN server has the content it will serve it, otherwise it will request it from the original server and cache it.

Pull-based CDN

Push-based CDN