tRPCttRPC
Powered by
Mark LM
tRPCโ€ข4y agoโ€ข
4 replies
Mark L

How can I cache a single procedure?

I've seen the docs on caching here: https://trpc.io/docs/caching

But that is caching the entire app router.

my app router has many "subrouters" (Not sure what you call them) and I need different cache times for different "procedures" in those routers.

For example I have some data that I would only want a 5 minute cache time for, but other data that can be cached for a week with no issues.

How can I apply a specific cache time to a procedure in trpc?

I tried using the
paths
paths
array in the app level caching, but it seems to sometimes include both paths that I want long caching for and paths that needs short caching? So I don't know how I would be able to use that to change the cache time properly.

For example I have a component that does multiple trpc queries, where some of those can be cached for a week without problems and others needs to be updated at least once a minute.
Response Caching | tRPC
The below examples uses Vercel's edge caching to serve data to your users as fast as possible.
Response Caching | tRPC
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

how can i get procedure name?
CaptainCCaptain / โ“-help
4y ago
How can I access ctx from inside of a procedure?
santiSsanti / โ“-help
3y ago
Can I alter the context in a procedure?
LiamLLiam / โ“-help
3y ago
Can I extend the procedure builder?
trachesTtraches / โ“-help
9mo ago