Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct expire calc & and Nested usage import in use-cache docs #71899

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/02-app/02-api-reference/01-directives/use-cache.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const nextConfig = {
biweekly: {
stale: 60 * 60 * 24 * 14, // 14 days
revalidate: 60 * 60 * 24, // 1 day
expire: 86400 60 * 60 * 24 * 14, // 14 days
expire: 60 * 60 * 24 * 14, // 14 days
},
},
},
Expand Down Expand Up @@ -239,6 +239,7 @@ For example, if you add the `use cache` directive to your page, without specifyi
```tsx filename="app/components/parent.tsx" highlight={5,6,19,20}
// Parent component
import { unstable_cacheLife as cacheLife } from 'next/cache'
import { ChildComponent } from './child'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to import it since it's in the same file. But, thinking about it, maybe we should make it more clearer that these can be in different folders by having two code blocks, then Parent can import the Child component.

Would you like to make that change @Developerayo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure! Pushed...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 🫶


export async function ParentComponent() {
'use cache'
Expand All @@ -257,6 +258,7 @@ import { unstable_cacheLife as cacheLife } from 'next/cache'
export async function ChildComponent() {
'use cache'
cacheLife('hours')
return <div>Child Content</div>

// This component's cache will respect the shorter 'hours' profile
}
Expand Down
Loading