0
0
NextJSframework~10 mins

Fetch caching behavior in NextJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to fetch data with caching disabled.

NextJS
const res = await fetch('/api/data', { cache: '[1]' });
Drag options to blanks, or click blank then click option'
Aforce-cache
Breload
Cdefault
Dno-store
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'force-cache' which caches data aggressively.
Using 'default' which may use cached data.
Using 'reload' which is not a valid cache option in Next.js fetch.
2fill in blank
medium

Complete the code to fetch data with caching enabled and revalidation after 60 seconds.

NextJS
const res = await fetch('/api/data', { cache: 'force-cache', next: { revalidate: [1] } });
Drag options to blanks, or click blank then click option'
A120
B60
C30
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 which disables caching.
Using 30 or 120 which are valid but not the requested 60 seconds.
3fill in blank
hard

Fix the error in the fetch call to correctly disable caching.

NextJS
const res = await fetch('/api/data', { cache: [1] });
Drag options to blanks, or click blank then click option'
A'no-store'
B'reload'
C'no-cache'
D'default'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'no-cache' which still allows caching with validation.
Using 'reload' which is not a valid cache option here.
4fill in blank
hard

Fill both blanks to fetch data with cache enabled and revalidate every 10 seconds.

NextJS
const res = await fetch('/api/data', { cache: '[1]', next: { revalidate: [2] } });
Drag options to blanks, or click blank then click option'
Aforce-cache
Bno-store
C10
D60
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'no-store' disables caching.
Setting revalidate to 60 instead of 10.
5fill in blank
hard

Fill all three blanks to fetch data with no caching and a custom header.

NextJS
const res = await fetch('/api/data', { cache: '[1]', headers: { '[2]': '[3]' } });
Drag options to blanks, or click blank then click option'
Ano-store
BAuthorization
CBearer token123
Dforce-cache
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'force-cache' which enables caching.
Missing the header key or value.