Comments (2)
To me this points to a huge complexity in the way that NextJS just simply extends fetch
with its own caching in the first place.
This is a very good question. I guess the answer here depends on where and how you want to cache database calls. Caching is a massive topic, and there are lots of ways to go about it depending on the platform that you leverage.
For example, if you're just running Payload on an Express server normally, you might not want to cache Payload API responses directly. But, other times, you might definitely want to cache and in turn logically cache-bust as documents are updated. In Payload Cloud, we are building a way to do this on Cloudflare that will run totally behind the scenes (cache GET responses, and cache-bust when updates happen).
As far as I understood it they payload client methods are directly using the mongodb api without fetch in-between correct?
This is correct. The Payload client talks directly to the database, no fetch involved.
So maybe it would be nice to add a getPayload payload function to next-payload package which is using getPayload from payload package but wraps every cacheable function (like find/findMany) in a cache function?
This depends largely on what you want to see happen and would only be useful in a subset of applications. For example, in this demo package, the [slug]/page.tsx
that you referenced above statically renders its content, so no caching to Payload is really necessary.
If you wanted to dynamically render certain pages, to me, that would imply that you would not want to render pages statically in the first place, so you should not be caching anything at all anyway.
But, if you did want to dynamically render pages with some dynamic content but other content from Payload cached, then that's where I think the react-cache
approach would come in. And that would be application-specific.
Does that make sense?
from next-payload-demo.
Related Issues (12)
- Stalled requests HOT 3
- Issue with login when deployed to AWS Lambda using SST HOT 3
- Using routes in app directory HOT 1
- Cold Start Performance HOT 1
- Triple duplicate of Autosaves & a toast warning that may be related HOT 1
- CORS error when trying to fetch from different IP HOT 1
- Integration with t3 stack HOT 1
- TypeError: tag[primaryAttributeKey].toLowerCase is not a function HOT 1
- Error on Vercel HOT 2
- Deploy with docker compose HOT 1
- [BUG] All layouts disappear from view when adding new layouts to existing page HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-payload-demo.