Why caching is so important:

Caching is the process of storing copies of files and data in a cache or some temporary space. By the use of caching, we fetch data very quickly. The best example of a caching tool is Cloudflare . I know Cloudflare is not the only caching tool, it is having other functionality also.

There are two main reasons for using caching in the application:

  1. Save the cost. Less amount of data sent over the network.
  2. Less response time.

Process of Caching:

The process of caching is so simple. Suppose you want to get some data from an API. In the first call, you will hit the API and get the data after that you will set or save that data in cache. In the future, if you want to get the same data, you don’t need to hit the API. First, you will check the data available in cache or not. If data available in the cache, then you will fetch data from the cache otherwise you will hit the API.

In this tutorial, first, we will get the data from fake API without Redis and then with Redis and check the difference of response time with visual representation.

Create a simple server in Express JS:

If you are new to the NodeJS world then please read my tutorial . In this tutorial, you will learn how to create an express js server and CRUD operations. Otherwise, follow the below steps to create a simple server in express js.

Create the package.json file:

npm init -y

#nodejs #redis #javascript #cache #typescript

Fasten Your Node JS Application with A Powerful Caching Mechanism using Redis
1.05 GEEK