---
title: "Discussion on \"How to exclude a route from caching in nest.js\" | Hashnode"
description: "Discussion on \"How to exclude a route from caching in nest.js\". Learn how to ignore a route from caching by overriding CacheInterceptor"
url: "https://hashnode.com/posts/how-to-exclude-a-route-from-caching-in-nestjs/61df8f356bf5f0642b8f1699"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to exclude a route from caching in nest.js](https://blog.shahid.codes/how-to-exclude-a-route-from-caching-in-nestjs?utm_source=hashnode&utm_medium=feed)

Learn how to ignore a route from caching by overriding CacheInterceptor

Jan 13, 2022 · 2 min read · blog.shahid.codes  
Updated Sep 10, 2022  
Read the article

-   [#nest](https://hashnode.com/tag/nest)
-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#caching](https://hashnode.com/tag/caching)
-   [#redis](https://hashnode.com/tag/redis)

## Written by

[Shahid Kamal](https://hashnode.com/@shahidcodes)

@shahidcodes

  
[View profile](https://hashnode.com/@shahidcodes)

Software Engineer

## Responses 2

Markdown supported · ⌘↵ to post

[Sergio](https://hashnode.com/@Sergio7)

[Sep 24, 2022](https://hashnode.com/posts/how-to-exclude-a-route-from-caching-in-nestjs/61df8f356bf5f0642b8f1699/comment/632f15373ac18d0d78a02164)

Great article Shahid!

Do I also need to include new interceptor/decorator somewhere else? Like app.module?

This example didn't work for me right away...

thanks,

[Shahid Kamal](https://hashnode.com/@shahidcodes)

[Oct 7, 2022](https://hashnode.com/posts/how-to-exclude-a-route-from-caching-in-nestjs/61df8f356bf5f0642b8f1699/comment/632f15373ac18d0d78a02164#reply-633ffe016971ffceb981fbc2)

If you want the cache interceptor to work on the global level then add below in the `app.module.ts`

```
providers: [
   {
     provide: APP_INTERCEPTOR,
     useClass: MyCacheInterceptor,
   },
 ]
```

[Yunus Emre INCE](https://hashnode.com/@yuunus90)

[May 4, 2022](https://hashnode.com/posts/how-to-exclude-a-route-from-caching-in-nestjs/61df8f356bf5f0642b8f1699/comment/627274a619a4772a6c29a3b8)

That is exactly what I was looking for. Thank you Shahid for clear explanation and code samples
