CDN | Caching |
---|---|
Reduced Latency | Reduced Latency |
High Availability | Lowered Server Load |
Improved Security | Improved UI |
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.
cache-control
header to tell browser how long this content should be cachedTypically stored in a separate cache server (like Redis)
Write-Around Cache
Write-Through Cache
Write-Back Cache
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:
LRU
Least recently usedFIFO
First In First OutLFU
Lest Frequently UsedUsually done by the database internally or by an external cache layer like Redis or Memcached
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.