Bird
0
0

What is the main purpose of the CacheInterceptor in NestJS?

easy📝 Conceptual Q11 of 15
NestJS - Interceptors
What is the main purpose of the CacheInterceptor in NestJS?
ATo handle authentication and authorization
BTo store responses and speed up repeated requests
CTo log all incoming requests
DTo format response data before sending
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of CacheInterceptor

    The CacheInterceptor caches HTTP responses to avoid recomputing them on repeated requests.
  2. Step 2: Compare with other options

    Logging, authentication, and formatting are handled by other interceptors or middleware, not CacheInterceptor.
  3. Final Answer:

    To store responses and speed up repeated requests -> Option B
  4. Quick Check:

    CacheInterceptor caches responses = C [OK]
Quick Trick: CacheInterceptor caches responses to speed up requests [OK]
Common Mistakes:
  • Confusing CacheInterceptor with logging interceptors
  • Thinking it handles security tasks
  • Assuming it formats data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes