How do cache components work with highly dynamic pages? #87059
Replies: 1 comment 2 replies
-
|
Hiyo, I am about to merge an update that fixes that example.
Then, at runtime, the first time a new dynamic params is requested, it render blocks, serves and saves to disk. The next time this param is requested it serves immediately. Without at least one sample parameter, (docs for this coming up too) - then there's no way to check what this route does. IIRC, we are trying to differentiate this, and other errors, so that you'd end up in a more appropriate error page. For example: https://nextjs.org/docs/messages/empty-generate-static-params would've been arguably more helpful. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I recently played around with cache components and I do find it very confusing.
I walked through the docs multiple times tried to get a good mental model of how it works but somehow it did not click yet.
What confuses me the most is that I tried to just use some of the examples from the docs and they do not work for me.
I do not understand what I am doing wrong and what am I missing.
It is stated multiple times that now with cacheComponents all pages are dynamic by default.
That is nice and actually what I expected, but I see some really strange things in use cases that should be easy and straight forward.
For example:
I copied this basic example here straight from the docs.
But it does not work.
I do get the
Runtime data was accessed outside of <Suspense>error.I do have a test repo running the latest canary here.
The error goes away if I do add
at the top of the file.
I do not understand why this is necessary and if this is the proper way to do it as I didn't find any docs on this.
In the current state I do not feel very confident adapting cacheComponents as it is very hard to grasp what is going on.
Feels almost like going from regular SSR to Client/Server Components all over gain.
In theory it should be straight forward but in practices there are either still many rough edges or I simply do not under stand it.
Wrapping all of my content in Suspense just seems like a bad idea and rework all components to move dynamic apis down is just not feasible in a large scale project.
I would love to have a very simple api to have something like ISR but on component level.
I thought cache components is exactly that but I do not get how to use it right 😓.
Please help I am desperate and confused 😆.
Beta Was this translation helpful? Give feedback.
All reactions