0
0
NextJSframework~20 mins

Full route cache in NextJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Full Route Cache Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What is the output of a Next.js page using full route cache with revalidation set to 10 seconds?

Consider a Next.js page that uses export const revalidate = 10; for full route caching. What happens when a user visits the page multiple times within 10 seconds?

NextJS
export const revalidate = 10;

export default function Page() {
  const time = new Date().toISOString();
  return <p>Current time: {time}</p>;
}
AThe page shows the same time for all visits within 10 seconds, then updates after 10 seconds.
BThe page updates the time on every visit regardless of the 10 seconds setting.
CThe page never updates the time once cached, even after 10 seconds.
DThe page throws an error because revalidate cannot be a number.
Attempts:
2 left
💡 Hint

Think about how Next.js uses the revalidate property to control cache duration.

📝 Syntax
intermediate
2:00remaining
Which option correctly enables full route caching with a 60-second revalidation in Next.js?

Choose the correct way to enable full route caching with a 60-second revalidation period in a Next.js page.

Aexport const cache = true;
Bexport const revalidate = 60;
Cexport const revalidate = '60';
Dexport const cache = { revalidate: 60 };
Attempts:
2 left
💡 Hint

Check the official Next.js syntax for revalidation.

🔧 Debug
advanced
2:00remaining
Why does this Next.js page update on every request despite revalidate set to 30?

Given the code below, the page shows a new time on every request despite revalidate set to 30. What is the most likely cause?

NextJS
export const revalidate = 30;

export default function Page() {
  const time = new Date().toISOString();
  return <p>Time: {time}</p>;
}
AThe revalidate value must be a string, not a number.
BThe page is missing a fetch call to trigger revalidation.
CThe page is a client component, so revalidate has no effect.
DThe revalidate property only works in API routes, not pages.
Attempts:
2 left
💡 Hint

Consider the difference between client and server components in Next.js caching.

🧠 Conceptual
advanced
2:00remaining
What happens when you set export const revalidate = 0; in a Next.js page?

In Next.js, what is the effect of setting export const revalidate = 0; in a page component?

AThe page is regenerated on every request (no caching).
BThe page throws a runtime error because 0 is invalid.
CThe page is cached indefinitely and never revalidated.
DThe page is cached for 0 seconds, then revalidated immediately after rendering.
Attempts:
2 left
💡 Hint

Think about what zero seconds means for caching duration.

state_output
expert
2:00remaining
What is the rendered output after 15 seconds if a Next.js page uses full route cache with revalidate=20 and shows current time?

A Next.js page exports export const revalidate = 20; and renders the current time. The page is first requested at 12:00:00 and cached. What time will the page show if requested again at 12:00:15?

NextJS
export const revalidate = 20;

export default function Page() {
  const time = new Date().toISOString();
  return <p>Time: {time}</p>;
}
AThe time from 12:00:20 because revalidation happens early.
BThe current time at 12:00:15 (fresh render).
CAn error because the cache is still valid.
DThe time from the first request at 12:00:00 (cached).
Attempts:
2 left
💡 Hint

Recall how revalidation timing affects cached page output.