Updated on 2024-06-12 GMT+08:00

How CDN Works

When a user accesses a website that uses CDN, the local DNS redirects the request to CDN using a CNAME record. Then, CDN finds the PoP that responds the fastest based on preset rules (including content types, geological locations, and network loads), and sends the PoP IP address to the user. With CDN, the user gets the requested content faster. The following figure shows the HTTP request process after CDN is used.

The HTTP request process is as follows:

  1. A user enters the domain name of a website (for example, www.example.com) in the browser. The browser sends a DNS request to the local DNS.
  2. The local DNS checks whether its cache includes the IP address of www.example.com. If yes, the local DNS returns the cached information to the user. If no, the local DNS sends a resolution request to the authoritative DNS.
  3. The authoritative DNS resolves the domain name. The domain name points to www.example.com.c.cdnhwc1.com (CNAME record of the domain name).
  4. The local DNS redirects the request to the CDN service.
  5. CDN performs intelligent domain resolution. It provides the local DNS with the IP address of the CDN PoP which responds the fastest.
  6. The user's browser obtains the IP address of this CDN PoP.
  7. The user's browser sends the access request to this CDN PoP.
    • If this CDN PoP has cached the content, it sends the desired resource to the user and ends the request.
    • If this CDN PoP has not cached the content, it sends a request to the origin server to pull the content. CDN caches the origin content on this CDN PoP based on custom cache policies. Then, the PoP sends the desired content to the user and ends the request. For details about how to configure a cache policy, see Cache Rules.