Dynamic APIs in caching #74945
Unanswered
Netail
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi 👋🏻
Both unstable_cache & "use cache" don't support the usage of dynamic APIs. Is this due to technical reasons or more of a safety measurement?
In our infrastructure we would like to pass down certain headers for both authentication & observability to outbound requests from the app. Sadly due to this limitation of the dynamic APIs within the cache function, we cannot easily pass on authentication headers. The response of every request is the same, it's just the outgoing requests having to forwards the authentication headers to access the internal API & some observability headers. (So it doesn't manipulate the result data, meaning cache could differ per user token) We could pass some of the headers into the function, but then those will be used to generate a cache key, meaning they would differ per request and missing all cache. I could imagine it being implemented as a safety percussion for when responses could differ based on headers, but we have use-cases where it's required for fetching & doesn't affect the data.
Beta Was this translation helpful? Give feedback.
All reactions