Recall & Review
beginner
What is a Cache Interceptor in NestJS?
A Cache Interceptor in NestJS is a tool that automatically stores the response of a request so that future requests can get the stored response quickly without running the full logic again.
Click to reveal answer
intermediate
How do you enable caching globally in a NestJS application?
You enable caching globally by importing and configuring CacheModule in the root module's imports array, and providing { provide: APP_INTERCEPTOR, useClass: CacheInterceptor } in the providers array.
Click to reveal answer
intermediate
Which decorator is used to disable caching on a specific route in NestJS?
The @CacheKey() decorator sets a custom cache key, but to disable caching on a route, you use the @CacheTTL(0) decorator or avoid applying the CacheInterceptor on that route.
Click to reveal answer
beginner
What is the role of CacheModule in NestJS caching?
CacheModule provides the caching functionality and configuration, like setting the store type (memory, redis), default TTL (time to live), and other options for caching in NestJS.
Click to reveal answer
intermediate
How does CacheInterceptor decide when to return cached data?
CacheInterceptor checks if a cached response exists for the request key. If yes, it returns the cached data immediately. If not, it runs the handler, caches the response, then returns it.
Click to reveal answer
What does CacheInterceptor do in NestJS?
✗ Incorrect
CacheInterceptor automatically caches responses to speed up repeated requests.
Which module must be imported to use caching in NestJS?
✗ Incorrect
CacheModule provides caching features and configuration in NestJS.
How do you apply CacheInterceptor globally in NestJS?
✗ Incorrect
You apply CacheInterceptor globally by providing it with the APP_INTERCEPTOR token in the root module's providers array.
What happens if CacheInterceptor finds no cached data for a request?
✗ Incorrect
If no cached data exists, CacheInterceptor runs the handler, caches the result, then returns it.
Which decorator can set a custom cache key in NestJS?
✗ Incorrect
@CacheKey() sets a custom key for caching responses.
Explain how CacheInterceptor works in NestJS and how it improves application performance.
Think about how saving answers helps you avoid repeating work.
You got /4 concepts.
Describe the steps to enable caching globally in a NestJS app using CacheModule and CacheInterceptor.
Remember the setup involves both module import and interceptor application.
You got /4 concepts.