Skip to main content

Profile picture for Ajeet Raina
Author:
Ajeet Raina, Former Developer Growth Manager at Redis

How to cache REST API responses Using Redis & NodeJS

My Image

This app returns the number of repositories a Github account has. When you first search for an account, the server calls Github's API to return the response. This can take some time. The server then adds the details of this slow response to Redis for future requests. When you search again, the next response comes directly from Redis cache instead of calling Github. The responses become much faster.

Pre-requisite

1. Install NodeJS

brew install node

2. Clone the repository

git clone https://github.com/redis-developer/basic-caching-demo-nodejs

3. Copy .env.sample to create .env

- REDIS_ENDPOINT_URI: Redis server URI
- REDIS_PASSWORD: Password to the server

4. Run frontend

cd client
yarn
yarn serve

5. Run backend

yarn
yarn start

Open up https://localhost:8081 and you can see a basic caching demo application up and running.

My Image