0
0
NextJSframework~20 mins

Why caching is central to Next.js - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Next.js Caching Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why does Next.js use caching for server components?
Next.js uses caching for server components mainly to:
AStore user passwords securely on the server
BAutomatically update the UI without developer input
CReduce repeated data fetching and speed up page rendering
DEnable client-side routing without page reloads
Attempts:
2 left
💡 Hint
Think about how caching helps avoid doing the same work multiple times.
component_behavior
intermediate
2:00remaining
What happens when cached data in Next.js expires?
In Next.js, when cached data for a page expires, the framework will:
ADelete the page and show a 404 error
BForce the user to reload the browser manually
CServe stale data indefinitely without updating
DFetch fresh data and update the cache before serving the page
Attempts:
2 left
💡 Hint
Consider how caching systems keep data fresh.
📝 Syntax
advanced
2:30remaining
Which Next.js code snippet correctly enables caching for a server component?
Select the code snippet that properly uses Next.js caching for a server component fetching data.
NextJS
import { cache } from 'react';

const fetchData = cache(async () => {
  const res = await fetch('https://api.example.com/data');
  return res.json();
});

export default async function Page() {
  const data = await fetchData();
  return <div>{data.message}</div>;
}
ACalls fetch() directly inside the component without caching
BUses the cache() wrapper around the async fetch function to memoize results
CCaches data by storing it in a global variable manually
DUses useState hook to cache data on the client side
Attempts:
2 left
💡 Hint
Look for the official React cache() function usage.
🔧 Debug
advanced
2:30remaining
Why does this Next.js server component fetch data on every request despite caching?
Given this code, why is data fetched every time instead of cached? import { cache } from 'react'; async function getData() { return await fetch('https://api.example.com/data').then(res => res.json()); } const cachedGetData = cache(getData); export default async function Page() { const data = await getData(); return
{data.title}
; }
AThe component calls getData() directly instead of cachedGetData(), so caching is bypassed
BThe cache() function is used incorrectly and does not memoize async functions
CNext.js disables caching by default in server components
DThe fetch URL is dynamic and prevents caching
Attempts:
2 left
💡 Hint
Check which function is actually called inside the component.
lifecycle
expert
3:00remaining
How does Next.js caching interact with Incremental Static Regeneration (ISR)?
In Next.js, when using ISR with a revalidate time, caching works by:
AServing a cached static page until the revalidate time expires, then regenerating the page in the background
BRegenerating the page on every request without caching
CDisabling caching completely to always show fresh data
DServing stale pages indefinitely without regeneration
Attempts:
2 left
💡 Hint
Think about how ISR balances caching and freshness.