Jun 03, 2022

5 Caching Implementations You Should Know

5 Caching Implementations You Should Know

In the article An Introduction to Caching Patterns we've covered 4 different techniques used to cache data and 3 of the biggest challenges associated with it.

In this article, we'll go over 5 of the most well-known and used caching implementations you should know as a developer, starting with in-memory caching.

In-memory Caching

In-memory caching refers to data being stored in the Random Access Memory, which is typically faster than traditional databases and disk-based hardware, as it supports higher request rates or IOPS — which stands for Input/Output Operations per Second — ultimately improving data retrieval performance and reduces cost at scale.

In-memory Caching

The most common implementation of this type of caching is based on key-value stores, which essentially means that whenever you provide the store a unique key or identifier it will provide a corresponding value back such as numbers, strings, arrays, lists and a variety of other data types.

In-memory Caching

This approach is one of the most preferred by developers as it is fast, efficient, and easy to understand.

Database Caching

Database caching refers to a database storing the result of frequently-queried data in an internal cache in order to avoid unnecessary or excessive query executions which in turn reduces its workload.

Database Caching

Just as an example loading a user’s profile information on any social media app involves complex queries over several data tables and running this query thousands of time in a short span without caching might actually put too much pressure on your database that could eventually crash or become too slow to respond resulting in cascading timeouts.

Browser Caching

Browser caching a.k.a. as HTTP caching refers to your browser storing resources such as text, images, stylesheets, scripts, and media files downloaded via HTTP whenever you load a web page for the first time.

This cache is used to make visited documents available for back and forward navigation, saving, viewing-as-source, etc. without requiring an additional trip to the server which also improves offline browsing whenever the website you’re trying to reach or your internet connection are down.

Browser Caching

So the next time you visit the same page, the browser can look into its own cache located on you machine for resources that were previously stored which ultimately reduces loading latency and network traffic.

Web Server Caching

Server caching refers to a dedicated caching service, usually a proxy server, that stores often requested and dynamically generated content such as complex web pages or files, which take time to be created.

Web Server Caching

That way it prevents servers from getting overloaded by reducing the work to be done and improves the page delivery speed.

CDN Caching

Finally, a CDN or Content Delivery Network refers to a network of proxy servers that cache content such as web pages, stylesheets, scripts, and media files and that are located between the user and the origin server.

Usually physically closer to the client’s location, its goal is to intercept the client’s request to a resource and deliver it immediately if it owns a copy of it or forward the request to the origin server.

CDN Caching

It allows to greatly reduce the network latencies and the number of requests made to the origin server for resources that are heavily requested or need to be loaded very fast.

Related posts