Fossil
TTCTheo's Typesafe Cult
•Created by Fossil on 4/12/2024 in #questions
How do you cache tRPC server responses w/Next App Router?
What is the correct way to define the cache for tRPC endpoints with
[email protected]
& Next App Router?
Cache-Control headers are overwritten by NextJs (https://nextjs.org/docs/app/api-reference/next-config-js/headers#cache-control)
Meaning the tRPC docs are not relevant (https://trpc.io/docs/server/caching)
I have validated this with a very simple trpc route returning new Date().toJSON()
. Current setup in create-t3-app appears to be 'no-cache' for these endpoints. NextJs will not respect cache-control headers set via responseMeta
in the fetchRequestHandler
, or via context.4 replies