Loading Depth Study
Preparing your workspace
Caching can reduce repeated work, while revalidation controls when previously generated or fetched data should be refreshed.
Production applications often need both performance and fresh data. Public course content may be cached and refreshed periodically, while highly personalized dashboard data may need more dynamic behavior. Next.js provides mechanisms for controlling when data or rendered results can be reused and when they should be refreshed. The correct strategy depends on how frequently data changes and how stale the UI is allowed to become.
Public course descriptions can be cached longer, while user progress should normally reflect recent changes more quickly.
const response = await fetch('https://example.com/api/courses', {
next: {
revalidate: 60
}
});
const courses = await response.json();The fetched course data can be reused for a limited period before Next.js considers it for revalidation.