Caching — Techniques · NestJS

Compute once, serve many times: CacheModule with a default lifetime, a route cached automatically with CacheInterceptor and invalidated on writes, and a cache-aside lookup by hand with the cache manager.

What you will learn

Read the theory for Caching

All Techniques lessons

All NestJS courses

loading types…

What you'll learn

  • Register CacheModule with a default ttl and explain what is stored and where
  • Cache a GET route with CacheInterceptor, choose its key with @CacheKey, and invalidate it on a write
  • Cache by hand with CACHE_MANAGER: get, set with a ttl, del and clear