The topic describes how CDN works by using an example.

In this example, your CDN domain is www.a.com and you have enabled the CDN domain. The following figure shows how CDN works after receiving an HTTP request from a user in Beijing.


How CDN works
  1. Before the user in Beijing sends a request to query a specific resource under www.a.com, it first initiates a domain name resolution request to LDNS.
  2. LDNS checks whether the cache contains an IP address record corresponding to www.a.com. If yes, LDNS directly returns the IP address to the user. If no, LDNS queries the IP address from the authorized DNS.
  3. After the authorized DNS resolves www.a.com, it returns the IP address of the corresponding CNAME www.a.tbcdn.com.
  4. LDNS sends the domain name resolution request to the Alibaba Cloud DNS scheduling system. Alibaba Cloud DNS assigns the IP address of the optimal node.
  5. LDNS receives the resolved IP address returned by Alibaba Cloud DNS.
  6. The user receives the resolved IP address.
  7. The user initiates an access request to the received IP address.
    • If the CDN node corresponding to the IP address (Beijing node in this example) has cached the requested resource, the resource is directly returned to the user, as shown in steps 7 and 8 in the figure. The request then ends.
    • If the CDN node corresponding to the IP address (Beijing node in this example) has not cached the resource, the CDN node requests the resource from the origin server. After the CDN node retrieves the resource, it automatically caches the resource according to the user-defined cache policy and also returns the resource to the user, as shown in the figure. The request then ends. For more information about how to configure a cache policy, see Configure caching.