CodePark/ questions / Metadata & SEO
START PRACTICINGPRACTICE
Frontend question · Next.js › Metadata & SEO

generateMetadata and the page both call fetch("https://api.example.com/post/1"). How many network requests happen during one render?

One, because identical fetch requests are memoized across generateMetadata, layouts and pages

One request is correct. Request memoization removes duplicate identical GET fetches within a single render pass, and that includes generateMetadata. For database calls, wrap the function in React cache() to get the same effect. The tempting "Two, one for each function" is wrong, because Next.js shares the first result with the second call.