Lesson 19 / الدرس 19
CDNs: copies closer to the reader / شبكات توصيل المحتوى: نسخ أقرب إلى القارئ
Distance costs time, and no amount of tuning beats the speed of light. The answer the whole industry uses is not a faster server — it is a nearer one.
المسافة تكلّف وقتًا، ولا يتغلب أي ضبط على سرعة الضوء. والجواب الذي تستخدمه الصناعة كلها ليس خادمًا أسرع — بل خادمًا أقرب.
Your server is in one place. A reader in Cairo and a reader in São Paulo cannot both be near it, and every request they make crosses that distance twice — once going, once coming back. Even on a perfect connection that is a fixed cost, paid on every single request.
A content delivery network is a fleet of machines in many cities, each holding a copy of your files. A reader is served from the nearest one. The idea is entirely boring — it is caching from lesson 16, moved out of the reader's browser and into a machine in their city — and it is the single largest speed improvement most sites can make.
How the request finds the near copy
Without a CDN:
reader in Cairo -> ~200 ms -> your server in Paris
With a CDN:
reader in Cairo -> ~10 ms -> CDN machine in Cairo (a hit — nothing further happens)
|
v only on a miss
your server in Paris
| Term | Means | What you want |
|---|---|---|
| Origin | Your actual server | To be asked as rarely as possible |
| Edge | A CDN machine near the reader | To answer nearly everything |
| Hit | The edge had a copy | Most requests |
| Miss | The edge had to ask the origin | Only the first, per city per file |
| Purge | Telling every edge to forget a file | After deploying a change |
The last row is the one that catches people. A CDN is another cache, so lesson 16's problem now exists in fifty cities at once.
no-store من الدرس 16 برهان أعلى بكثير، لأن النسخة المخزّنة صارت على جهاز يخدم مدينة كاملة.What else arrives with it
Because every request passes through the edge before reaching you, a CDN is also where several other things are done: absorbing a flood of traffic that would otherwise reach your one machine, terminating the TLS from lesson 12 near the reader so the handshake is quick, and compressing or resizing images on the way past. Speed is the reason people adopt one; these are the reasons they keep it.
cache — فمعظم الشبكات تضيف واحدة قيمتها HIT أو MISS. أعد التحميل مرتين وراقب MISS وهي تصير HIT.Check yourself / اختبر نفسك
1. What does a CDN actually change about a request?
The distance is the cost, and a near copy is the only way to reduce it. Nothing about the URL or the protocol changes.
2. How does the reader end up talking to the near machine?
It is lesson 4 doing something clever with the same lookup. The reader never knows, and the address they typed is unchanged.
3. Which page must a CDN never cache?
The edge cannot tell visitors apart. A cached personal page can be served to the next person who asks for that address — in that whole city.
Score / النتيجة: 0 / 3