How does CloudFront (CDN) improve performance, and what do you cache vs not?
Reviewed by Gurusankar M.
Short Answer
CloudFront caches content at edge locations near users, cutting latency and offloading origin traffic. Cache static assets aggressively (long TTL + cache-busting filenames); use short/no cache for dynamic/personalized responses. Control behavior with cache policies (TTLs, which headers/cookies/query strings form the cache key).
On this page
Concept Made Simple
Coffee Chat Question
“How does CloudFront (CDN) improve performance, and what do you cache vs not?”
Remember It Faster
Mind Map Answer
- Edge cache
- content near users → low latency
- Static
- long TTL + versioned filenames
- Dynamic
- short/no cache, forward needed headers
- Cache key
- headers/cookies/query params
Think Beyond the Expected
What If?
Users see stale content after a deploy — how do you avoid it without manual invalidations?
Use content-hashed filenames (app.a1b2c3.js) so each deploy produces new URLs the CDN treats as new objects — old cached files just age out. This 'cache-busting' avoids costly/global invalidations and eliminates stale-asset bugs.
Real World
CDN in front of S3/ALB with hashed asset filenames is standard for web performance; relying on manual invalidations instead of cache-busting is a common source of stale-content incidents.
Interviewer's Expectation
Keywords they're listening for:
- edge caching/latency
- static long-TTL + cache busting
- dynamic short/no cache
- cache key config
- invalidation vs versioning
Common Mistakes
- Caching personalized/dynamic responses
- Relying on manual invalidations
- Cache key including too many varying headers (low hit rate)
Best Practices
- Cache-bust static assets with hashed names
- Short/no cache for dynamic content
- Tune the cache key for a high hit rate
Follow-up Questions
- How does the cache key affect hit rate?
- When do you invalidate vs version?
- Origin Access Control for private S3 origins?
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: S3 (AWS) Interview question: "How does CloudFront (CDN) improve performance, and what do you cache vs not?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair