Rest API - Caching StrategiesYou 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, publicBCache-Control: private, max-age=300, no-storeCCache-Control: public, no-cache, max-age=300DCache-Control: public, max-age=300, must-revalidateCheck Answer
Step-by-Step SolutionSolution: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.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.Final Answer:Cache-Control: public, max-age=300, must-revalidate -> Option DQuick 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:MISTAKESUsing 'private' instead of 'public'Adding 'no-store' disables cachingMisusing 'no-cache' for timed revalidation
Master "Caching Strategies" in Rest API9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Rest API Quizzes API Testing and Monitoring - Postman collection organization - Quiz 15hard API Testing and Monitoring - Contract testing - Quiz 2easy API Testing and Monitoring - Postman collection organization - Quiz 9hard Advanced Patterns - Composite operations (multi-resource) - Quiz 4medium Batch and Bulk Operations - Batch update patterns - Quiz 1easy Caching Strategies - If-None-Match and 304 responses - Quiz 11easy Webhooks and Events - Webhook payload design - Quiz 3easy Webhooks and Events - Webhook payload design - Quiz 5medium Webhooks and Events - Why webhooks push notifications - Quiz 7medium Webhooks and Events - Webhook testing strategies - Quiz 4medium