Allow use cache; without forcing cacheComponents?
#86396
Replies: 1 comment
-
|
Tested & Trusted Hi there! I’ve been exploring the new After digging deeper into how My question is: Is it possible to continue dynamically rendering most pages, but selectively cache expensive functions using
I may be thinking about this the wrong way, so any clarification on intended usage patterns or upcoming flexibility would be really appreciated. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there! I came across the new
use cachefeature and was really excited by it. I tried to incorporate as a lightweight way to cache a function call that fetches a large amount of data from a database by marking a server-side function with ause cache;directive. I was a bit perplexed to then see many Uncached data was accessed outside of<Suspense>errors show up across my site and cause errors during build.After doing some digging and learning more about
use cacheand PPR, I understand the motivation behind requiring<Suspense />for dynamic data access, but I can't help but feel that this is a bit of a strong requirement, especially for those who might want to incrementally migrate to this approach. For larger sites like mine which extensively use dynamic rendering, it feels like a tall order to migrate many different parts of the site to this model.Is there a way to keep dynamically rendering pages in my site, but occasionally cache expensive functions using
use cacheon a case-by-case basis? Perhaps I'm thinking about this incorrectly, but nothing about theuse cache;idiom in isolation seems to imply that uncached, dynamically rendered components should be disallowed. Has there been any thought about having a more flexible option, perhaps e.g. an option to disable the above error messages or to have auseCacheconfig option that allows a separate, less strict version ofcacheComponents?Beta Was this translation helpful? Give feedback.
All reactions