📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

How do you invalidate cached API responses across several instances and a CDN when the data changes?

Intermediate Theory Intermediate

🎯 Key points

  • In-memory eviction only clears one instance
  • Redis output cache store shares evictions across instances
  • CDN purge is slow and rate limited
  • Short s-maxage bounds edge staleness
  • Versioned URLs create a new cache key, so no purge is needed
  • ETags plus If-None-Match give cheap revalidation (304)
  • Read-your-own-writes and stale-while-revalidate for user experience

⏱ 30-second answer

Use a shared output cache store (Redis) so EvictByTagAsync clears every instance, not just the one that handled the write. At the CDN, keep s-maxage short or purge by path through the CDN API (an Azure Front Door purge can take minutes). For data that must change quickly, avoid purging altogether: content-hash or versioned URLs (/catalogue?v=42) make the new version a new cache key, and ETags let clients revalidate cheaply with If-None-Match and get 304 when nothing changed. Decide the acceptable staleness per endpoint; stale-while-revalidate keeps responses fast while the edge refreshes, and the client should re-read after its own write so users see their change.

🔍 What the interviewer is checking

Checks multi-layer invalidation design

↩ Usually asked after

More in API Reliability

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me