Theo's Typesafe CultTTC
Theo's Typesafe Cult2y ago
25 replies
Kenzo

Caching does not work with trpc in Next, what would you do?

Hi, I someone in trpc discord said:

Currently documented tRPC cacheing methods (https://trpc.io/docs/server/caching) won't work as they rely on setting headers which NextJs now overrides (https://nextjs.org/docs/app/api-reference/next-config-js/headers#cache-control)

And this is a big problem, what's a good alternative if I really need to cache my trpc calls?
Also, maybe t3 stack should change trpc?
Is there any other way to cache db calls?
Next cache works only for fetch calls.
@nexxel is this an issue for t3?
Thanks
The below examples uses Vercel's edge caching to serve data to your users as fast as possible.
Response Caching | tRPC
Add custom HTTP headers to your Next.js app.
next.config.js Options: headers | Next.js
Was this page helpful?