#Controller cache doesn't work without CacheInterceptor

3 messages · Page 1 of 1 (latest)

fallow burrow
#

So I recently figured out that cache on a method/controller level doesn't work if you don't use CacheInterceptor on the controller level. I remember it working with just CacheTTL(milliseconds). Did something change or is it a intended behavior?

Here's a minimal repo with the issue: https://github.com/OSA413/nestjs-cache-problem (npm i && npm start)

If you comment out the @UseInterceptor(CacheInterceptor) in src\app.controller.ts file you'll see that the cache stops working.

GitHub

Contribute to OSA413/nestjs-cache-problem development by creating an account on GitHub.

daring swan
#

This is expected. If it worked before, you probably mounted the cache interceptor globally

#

The "ChacheTTL" only sets metadata on the route that the interceptor can read. It doesn't add any behavior itself.