I have created a custom CacheInterceptor
to change the cache key:
@Injectable()
export class HttpCacheInterceptor extends CacheInterceptor {
trackBy(context: ExecutionContext): string | undefined {
const request = context.switchToHttp().getRequest<FastifyRequest>()
return `${request.hostname}:${request.url}`
}
}
and use it as so in AppModule
providers: [
AppService,
{
provide: APP_INTERCEPTOR,
useClass: HttpCacheInterceptor
}
]
I’d like to be able to disable the cache entirely based on value from ConfigService though, but at a loss how to inject the ConfigService
in this scenario?
New contributor
sonooby is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.