I have an NestJS REST api and noticed that Cache-Control header is not sent. I am not sure if i miss something with nestjs but asking google how to cache REST API get response with nestjs only leads me to NestJs cache manager which is on server in memory cachig. So I have couple of questions:
Thanks for the answers
Yes you can set it with the header annotation:
https://docs.nestjs.com/controllers#headers
@Get()
@Header('Cache-Control', 'max-age=3600')
get() {
return 'This action adds a new cat';
}
btw. its in the rest definition that the should be cachable, just not every method: https://en.wikipedia.org/wiki/Representational_state_transfer#Cacheability
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.