Skip to content
tezvyn:

Content Delivery Network (CDN): Serving Content from the Edge

Source: Wikipedia: Content delivery networkEasyHow cards are made

Content Delivery Network (CDN): Serving Content from the Edge

A CDN is like a global chain of convenience stores for your website's assets. It caches copies closer to users for faster delivery, speeding up images, CSS, and video. The footgun: accidentally caching private user data and serving it to everyone.

Why it exists

The internet's speed is limited by physics. A request from a user in Australia to a server in North America has to travel thousands of miles, introducing latency that makes a site feel slow. CDNs were created to solve this physical distance problem by moving content closer to the end user.

The mental model

A CDN is like a global franchise of convenience stores for your website's data. Instead of every customer traveling to your single, central warehouse (the origin server), they can get common items from a local store (a CDN edge server) in their neighborhood. This is much faster and reduces the load on the main warehouse.

How it works

A CDN is a network of proxy servers, called edge locations, distributed around the world. When a user requests a file, like an image, their request is routed to the nearest edge location. If that server has a cached copy (a "cache hit"), it serves it immediately. If not (a "cache miss"), the edge server fetches the file from your origin server, delivers it to the user, and then stores a copy for future requests from that same region.

When to use it

CDNs are ideal for serving static content that doesn't change frequently per user. This includes assets like images, CSS stylesheets, JavaScript files, fonts, and pre-recorded video or audio streams. Anything that is the same for all users is a great candidate for a CDN.

When not to use it

Avoid caching highly dynamic or personalized content. For example, the contents of a user's shopping cart, their private account page, or API responses containing sensitive information should not be cached on a public CDN edge server. Doing so could leak one user's private data to another.

One canonical example

A news website based in New York publishes an article with many images. Without a CDN, a reader in London has to download every image from the New York server, resulting in a slow page load. With a CDN, the first London reader's request causes the CDN's London edge server to cache the images. All subsequent readers in the UK get the images almost instantly from the London server, making the site feel much faster.

Interview question

Which type of content should generally NOT be served through a Content Delivery Network (CDN)?

  • a.Global JavaScript libraries used across many pages
  • b.A user's unique shopping cart detailsCorrect
  • c.Static image files for a blog post
  • d.Pre-recorded video lectures for an online course
Why?

The card explicitly states that highly dynamic or personalized content, such as a user's shopping cart, should not be cached on a CDN to prevent data leaks. Static assets like images, JavaScript, and pre-recorded videos are ideal for CDN delivery.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles