A CDN works by caching content on a network of edge servers located in various geographical locations. When a user requests content, the CDN directs the request to the nearest edge server. This server delivers the cached content, reducing the time it takes for the page to load. For dynamic content, the CDN can still optimize delivery by leveraging advanced algorithms and routing techniques.