0
0
NextJSframework~20 mins

Revalidation strategies (time-based) in NextJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Next.js Revalidation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when using revalidate: 10 in Next.js?
Consider a Next.js page using export const revalidate = 10;. What is the behavior of this page after the first request?
NextJS
export const revalidate = 10;

export default function Page() {
  return <p>Current time: {new Date().toISOString()}</p>;
}
AThe page is regenerated at most once every 10 seconds after the first request.
BThe page is statically generated once and never updated again.
CThe page is regenerated exactly every 10 seconds, regardless of requests.
DThe page is regenerated on every request, ignoring the 10 seconds.
Attempts:
2 left
💡 Hint
Think about how Next.js uses the revalidate time to update static pages.
📝 Syntax
intermediate
1:30remaining
Identify the correct way to set time-based revalidation in Next.js 14
Which of the following code snippets correctly sets a 30-second revalidation time for a Next.js page using the App Router?
Aexport const revalidate = 30;
Bexport const revalidate = '30s';
Cexport const revalidate = true;
Dexport const revalidate = 30000;
Attempts:
2 left
💡 Hint
Check the type and value expected for revalidate in Next.js.
🔧 Debug
advanced
2:30remaining
Why does the page never update despite revalidate set?
A developer sets export const revalidate = 60; in a Next.js page but notices the page content never updates after deployment. What is the most likely cause?
AThe developer forgot to restart the Next.js server after setting revalidate.
BThe page is a Server Component and revalidate only works with Client Components.
CThe page is inside the <code>app</code> directory but uses <code>getStaticProps</code> which is ignored.
DThe revalidate value must be a string, so 60 is ignored.
Attempts:
2 left
💡 Hint
Consider how Next.js handles data fetching methods in the App Router.
state_output
advanced
2:00remaining
What is the output behavior of ISR with revalidate: 0?
If a Next.js page has export const revalidate = 0;, what will be the behavior when users request the page?
NextJS
export const revalidate = 0;

export default function Page() {
  return <p>Time: {new Date().toISOString()}</p>;
}
AThe page regenerates every 0 seconds, causing a server error.
BThe page is generated once at build time and never updates.
CThe page regenerates only once every minute regardless of the 0 value.
DThe page is regenerated on every request, showing the current time always updated.
Attempts:
2 left
💡 Hint
Think about what 0 seconds means for revalidation timing.
🧠 Conceptual
expert
3:00remaining
How does Next.js handle concurrent requests during revalidation?
When a Next.js page with revalidate: 10 is requested by multiple users at the same time after the cache expires, how does Next.js handle regeneration to avoid multiple builds?
ANext.js regenerates the page separately for each request, causing multiple builds.
BNext.js regenerates the page once and serves the stale cached page to other requests until regeneration finishes.
CNext.js blocks all requests until the page is regenerated, causing delays.
DNext.js serves a 503 error to all requests during regeneration.
Attempts:
2 left
💡 Hint
Consider how Next.js optimizes regeneration to reduce server load.