FUNDAMENTALS & NETWORKING · SUBTOPIC
Edge Computing & Cache-Control
Run lightweight logic near users and control freshness with HTTP caching headers.
IntermediatePart of CDN & Edge Computing
Subtopics in CDN & Edge Computing (2)
In plain words
Edge computing lets small snippets of your code run right inside the nearby CDN tower - checking logins, redirecting users, or A/B testing without a trip to your main data center.
Think of it like…
Ticket checkers at the stadium gate (the edge) turning away invalid tickets before anyone enters the building.
Loading interactive diagram
Loading interactive exercise
Theory & how it works
Essential Cache-Control directives
public, max-age=3600 allows CDNs and browsers to cache for 1 hour. private allows the user’s browser to cache, but forbids shared CDNs from caching sensitive personal data.
stale-while-revalidate=60 is a superpower: serve the slightly stale cached copy immediately (0 ms wait!) while silently refreshing it in the background.
Key points & practical guide
Summary checklist
- Never cache
privateuser responses on shared CDN edges - Use
stale-while-revalidatefor fast feeds and product pages - Run JWT verification, geo-routing, and bot protection at the edge
When to use it
- Global latency optimization
- Auth token checks and A/B testing at the network edge
Watch out for
- Putting heavy database queries inside edge workers (they usually don’t have a nearby primary DB)
Quick check
Loading quiz