Bird
0
0

Why does this Remix loader not cache the response as expected?

medium📝 Debug Q7 of 15
Remix - Performance
Why does this Remix loader not cache the response as expected?
export async function loader() {
  return new Response('Data', {
    headers: { 'Cache-Control': 'max-age=0, must-revalidate' }
  });
}
ACache-Control header is ignored without ETag
Bmax-age=0 forces cache to expire immediately, so no caching occurs
Cmust-revalidate disables caching completely
DResponse body must be JSON to cache
Step-by-Step Solution
Solution:
  1. Step 1: Understand max-age=0 effect

    max-age=0 means the cached response expires immediately, so browser must revalidate every time.
  2. Step 2: Analyze must-revalidate role

    must-revalidate requires revalidation but does not disable caching alone.
  3. Final Answer:

    max-age=0 forces cache to expire immediately, so no caching occurs -> Option B
  4. Quick Check:

    max-age=0 means no effective caching [OK]
Quick Trick: max-age=0 disables caching by immediate expiration [OK]
Common Mistakes:
MISTAKES
  • Thinking must-revalidate disables caching
  • Assuming ETag is required for caching
  • Confusing response body type with caching

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes