Bird
0
0

Which of the following is the correct way to set a Cache-Control header in a Remix loader?

easy📝 Syntax Q12 of 15
Remix - Performance
Which of the following is the correct way to set a Cache-Control header in a Remix loader?
Areturn new Response(data, { headers: { 'Cache-Control': max-age=3600 } })
Breturn new Response(data, { cacheControl: 'max-age=3600' })
Creturn new Response(data, { headers: { 'cachecontrol': 'max-age=3600' } })
Dreturn new Response(data, { headers: { 'Cache-Control': 'max-age=3600' } })
Step-by-Step Solution
Solution:
  1. Step 1: Check correct header syntax

    HTTP headers are case-insensitive but usually written as 'Cache-Control' with quotes around the value.
  2. Step 2: Verify Remix Response usage

    Remix uses the Response constructor with a headers object; the header key must be a string and value a string.
  3. Final Answer:

    return new Response(data, { headers: { 'Cache-Control': 'max-age=3600' } }) -> Option D
  4. Quick Check:

    Headers object with 'Cache-Control' string value [OK]
Quick Trick: Headers keys and values must be strings in Response [OK]
Common Mistakes:
MISTAKES
  • Using 'cacheControl' instead of 'Cache-Control'
  • Missing quotes around header values
  • Using unquoted max-age value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes