Avoiding excessive redundant data in RSC payloads by allowing proper data sharing between pages #67582
Unanswered
gkielwasser
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
-
Indeed, the RSC payload is statically built per page. It encapsulates all the data fetched in any server component from any segments composing the page route, in case that data is passed to a client component.
Let's say I have 1,000 pages sharing the same 10KB of common data that will be used by client components. How can I share this data between those pages to:
1- Avoid storing the same common data in the cache for all 1,000 pages
2- Prevent a user session that visits or prefetches multiple pages from downloading the common data multiple times (even if from cache, we want to avoid fetching data that is already in the browser).
3- Ensure pages that are purely static remain static without turning them into dynamic pages (using
force-dynamic
) just to share the common data. Indeed turing dynamic a part of the segment, the rsc payload would not contains data contained in upper leafs.4- Avoid loading the common data on the client side which defeats totally SSR
Having a context in a client component that is fed by a server component won't work. This will result in those data being fetched multiple times accross pages.
Here is an issue with a clean CodeSandbox where data redundancy between pages is easily noticeable. Additionally, you can observe the browser fetching the same data multiple times during navigation if the pages share common data: #67347 (comment)
Thanks
Beta Was this translation helpful? Give feedback.
All reactions