mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
The `use-cache-dev` suite only covers dev-mode HMR behavior of `use cache`, so it belongs under `test/development/app-dir` alongside the other `cache-components-dev-*` suites rather than in `test/e2e`. Because `test/development` runs only in dev mode and is never deployed, the production-mode placeholder guard, the `skipDeployment` option, and the `if (skipped)` early return are all dropped. The three test manifests that referenced the old path are updated. --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
17 lines
508 B
TypeScript
17 lines
508 B
TypeScript
async function getCachedData() {
|
|
'use cache'
|
|
|
|
return { text: 'foo', mathRandom: Math.random() }
|
|
}
|
|
|
|
export async function GET() {
|
|
const { text, mathRandom } = await getCachedData()
|
|
|
|
// Read outside of "use cache" so it reflects the recompiled module on every
|
|
// request. This lets the test distinguish a stale cache hit (where `text`
|
|
// keeps its old value) from the module never having recompiled at all.
|
|
const uncachedText = 'foo'
|
|
|
|
return Response.json({ text, mathRandom, uncachedText })
|
|
}
|