NestJs Caching With Redis

The ultimate guide to implementing caching in NestJs with Cache Interceptor, Cache Manager and Redis

Vladimir Agaev
9 min readJul 30, 2022
Photo by Jandira Sonnendeck on Unsplash

Congratulations! You have deployed a NestJs application that is gaining traction! A lot of users are using your app, the traffic goes viral.

At some point, you receive emails complaining that your website is slow. You’ve probably heard that caching can solve the problem, but you are unsure how to implement it.

You came to the right place!

In this article, I will explain caching, why you need it and how to implement it in your NestJs application.

What is Caching?

Before we start, please note that you can find the github repository with the completed project

Caching is a fairly old technique designed to improve your application’s performance and reliability.

Caching involves saving frequently requested data in an intermediary store called the “cache store” to avoid unnecessary calls to the primary database.

An HTTP request asking for data cached by the server will receive it directly from the cache store instead of getting it from a database. Which is much faster!

--

--