How do you invalidate a CDN cache after a deployment?
IntermediateScenarioLoad Balancing, Proxies & CDN
Answer
Situation read → You must clear stale objects or avoid needing to.
What I'd do →
- Prefer versioned file names (
app.4f3a9c.js) with long TTLs and a short TTL onindex.html - For emergencies invalidate paths:
aws cloudfront create-invalidation --distribution-id E123 --paths '/index.html' '/api/config*' - Watch cost: first 1,000 paths a month are free, then billed
- Verify with
curl -sIand checkX-Cache: Hit from cloudfrontorMiss
Why → Immutable asset names turn invalidation from a process into a non-event.
Interview tip → Say you design cache keys so deploys never need a global purge.
More on Load Balancing, Proxies & CDN
What is the difference between a Layer 4 and a Layer 7 load balancer?BeginnerWhen do you choose an ALB and when an NLB in AWS?BeginnerForward proxy versus reverse proxy: what is the difference?BeginnerHow do health checks work on a load balancer and what makes a good one?BeginnerWhat are sticky sessions and why would you avoid them?BeginnerWhat does a CDN do and when does it help?Beginner