Files
Jude GaoandGitHub 07d2820645 Track use cache usage (#75007)
We’re updating the SWC transform to
[track](https://nextjs.org/telemetry) how the "use cache" directive is
used during builds. Each use of "use cache" is counted based on the
handler it’s linked to.

By default, "use cache" counts toward a feature called
"useCache/default". If a custom handler is defined in the Next.js config
(e.g., "custom"), then "use cache: custom" will count toward
"useCache/custom".

The build process will collect these counts and combine them across all
source files and workers. This data is reported under the
NEXT_BUILD_FEATURE_USAGE event, allowing us to filter by "useCache/*" to
see how often each cache handler is used.

*Only support webpack prod build for now.

Closes NDX-683
2025-01-22 11:41:04 -05:00

20 lines
423 B
React

async function getCachedRandom(n) {
'use cache'
return String(Math.ceil(Math.random() * n))
}
async function getCachedRandomV2(n) {
'use cache: custom'
return String(Math.ceil(Math.random() * n))
}
export default async function Page() {
const random = await getCachedRandom(10)
const randomV2 = await getCachedRandomV2(10)
return (
<h1>
Hello from cached page! {random} {randomV2}
</h1>
)
}