The variable revalidate must be exported to affect caching.
Step 2: Identify missing export
Without export, Next.js ignores the variable and uses default caching.
Final Answer:
Missing export keyword for revalidate -> Option A
Quick Check:
revalidate must be exported to disable caching [OK]
Hint: Always export revalidate to control caching [OK]
Common Mistakes:
Forgetting to export revalidate
Thinking revalidate must be non-zero
Confusing functional and class components
5. You want a Next.js page to always show fresh data but only disable caching for authenticated users. Which approach correctly opts out of caching only for them?
hard
A. Set revalidate = 0 inside getStaticProps conditionally
B. Set export const revalidate = 0; unconditionally in the page file
C. Use server-side rendering with export const dynamic = 'force-dynamic'; and check auth inside
D. Add Cache-Control: no-store header in _app.js for all requests
Solution
Step 1: Understand conditional caching needs
Disabling caching only for authenticated users requires dynamic rendering based on request context.
Set export const revalidate = 0; unconditionally in the page file disables caching for all users; Set revalidate = 0 inside getStaticProps conditionally is invalid because revalidate is static; Add Cache-Control: no-store header in _app.js for all requests affects all requests globally.
Final Answer:
Use server-side rendering with export const dynamic = 'force-dynamic'; and check auth inside -> Option C