Bird
0
0

To cache a Remix loader response for 5 minutes but ensure it updates immediately when data changes, which Cache-Control header is most appropriate?

hard📝 Conceptual Q8 of 15
Remix - Performance
To cache a Remix loader response for 5 minutes but ensure it updates immediately when data changes, which Cache-Control header is most appropriate?
ACache-Control: max-age=600, public
BCache-Control: max-age=300, stale-while-revalidate=600
CCache-Control: no-cache
DCache-Control: max-age=300, must-revalidate
Step-by-Step Solution
Solution:
  1. Step 1: Understand max-age

    max-age=300 caches the response for 5 minutes (300 seconds).
  2. Step 2: Understand must-revalidate

    must-revalidate forces the client to revalidate the cache after it expires, ensuring fresh data.
  3. Step 3: Compare options

    Cache-Control: max-age=300, must-revalidate ensures caching for 5 minutes but requires validation after expiration, so data updates immediately.
  4. Step 4: Why others are incorrect

    B allows stale data for 10 minutes, which delays updates; C disables caching; D caches for 10 minutes, longer than desired.
  5. Final Answer:

    Cache-Control: max-age=300, must-revalidate -> Option D
  6. Quick Check:

    must-revalidate ensures fresh data after max-age expires [OK]
Quick Trick: Use must-revalidate to force fresh data after cache expires [OK]
Common Mistakes:
MISTAKES
  • Using stale-while-revalidate when immediate update is needed
  • Setting too long max-age causing stale data
  • Using no-cache which disables caching

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes