Distributed Caching

Caching layers

Below are some of the available caching layers

DNS Cache

When you visit a URL, for example, www.google.com, a request is made to the DNS server to map the URL to an IP Address. The resolved IP Address gets stored in the user's web browser or the user’s OS to quickly retrieve it the next time it’s requested. This is much more efficient compared to resolving the IP Address every time you visit a website.

Client Side Cache

Client Side caching is also known as browser caching. Once the client has requested data from the server, it may store data on the browser. Client cache is efficient because it allows the browser to access data without contacting the web server, therefore, improving the latency. Clients store files after requesting them for the first time with an expiration time on the settings.

Once the files expire, the client can send a re-validation request to the server. If the server contains a newer version, re-validation fails and the server returns a full file. If the file is unchanged, the server returns a 304(Not Modified). The cache keeps the file and refreshes the expiration time. The client and server only exchange the headers information which is faster than reloading the files.

Content Delivery Network(CDN)

The browser caches most of the static content that appears on the web page to lower the load times. Browsers store the data until their time to live expires or until the memory cache is full. On the server side, various web caching techniques such as CDN(reverse proxy) can be used to improve the performance of a website. A Content Delivery Network works like a browser cache, caching content such as images, videos, and static web pages in proxy servers that are located closer to the user than the original servers.

A CDN delivers content faster because the servers are closer to the user making the request. Think of CDN as a chain of grocery stores. Instead of going to the farm where food is grown which could be miles away, a shopper goes to their local grocery store. The CDN caches the “grocery” content so pages are served more quickly. Cached content remains in the CDN as long as users continue requesting it. Examples of CDN services are Cloudflare, Amazon CloudFront, and Azure CDN.

Application Server Cache

Server-side caching utilizes key/value stores to cache data in memory. Requested data can be cached in memory instead of making requests to the database. In Memory, the cache delivers sub-millisecond response times enabling hundreds of thousands of requests per second. This is way faster than making requests to the database, therefore, reducing latency, increasing throughput, and easing the load off your relational database. Examples of Key/Value stores are Redis, Amazon’s DynamoDB, and Microsoft Cassandra.

Database Cache

A database cache layer can be applied to any relational and non-relational databases. Most databases usually include some level of caching in the default configuration. Tweaking these settings for specific usage patterns greatly improves performance.

Whenever you're ready

There are 4 ways we can help you become a great backend engineer:

The MB Platform

Join 1000+ backend engineers learning backend engineering. Build real-world backend projects, learn from expert-vetted courses and roadmaps, track your learnings and set schedules, and solve backend engineering tasks, exercises, and challenges.

The MB Academy

The “MB Academy” is a 6-month intensive Advanced Backend Engineering BootCamp to produce great backend engineers.

Join Backend Weekly

If you like post like this, you will absolutely enjoy our exclusive weekly newsletter, Sharing exclusive backend engineering resources to help you become a great Backend Engineer.

Get Backend Jobs

Find over 2,000+ Tailored International Remote Backend Jobs or Reach 50,000+ backend engineers on the #1 Backend Engineering Job Board