Bird
0
0

You want to cache a resource publicly but ensure it is revalidated after 5 minutes. Which Cache-Control header should you use?

hard📝 Application Q8 of 15
Rest API - Caching Strategies
You want to cache a resource publicly but ensure it is revalidated after 5 minutes. Which Cache-Control header should you use?
ACache-Control: no-store, max-age=300, public
BCache-Control: private, max-age=300, no-store
CCache-Control: public, no-cache, max-age=300
DCache-Control: public, max-age=300, must-revalidate
Step-by-Step Solution
Solution:
  1. Step 1: Identify directives for public caching and revalidation

    'public' allows shared caches, 'max-age=300' sets 5 minutes freshness, 'must-revalidate' forces revalidation after expiry.
  2. Step 2: Eliminate incorrect options

    'private' restricts caching to single user, 'no-store' disables caching, and 'no-cache' forces revalidation always, not after 5 minutes.
  3. Final Answer:

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

    public + max-age + must-revalidate = shared cache with revalidation [OK]
Quick Trick: Use 'public, max-age=seconds, must-revalidate' for shared cache with expiry [OK]
Common Mistakes:
MISTAKES
  • Using 'private' instead of 'public'
  • Adding 'no-store' disables caching
  • Misusing 'no-cache' for timed revalidation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes