A content delivery network is an important aspect of the internet infrastructure used without understanding what happens behind the scenes. Just like any other technology pieces, CDNs are not magic and works in a straightforward and simple manner. When a browser places a request for a resource, a DNS request comes first because making a DNS request is similar to looking for a phone number in the directory. What the browser does is to give the domain name and receives an IP address. The browser will use the IP address to contact the web server for subsequent requests. For your small commercial website or your simple blog, a domain name might possess one IP address while large websites and applications may have a domain name possessing multiple IP addresses.
Read also: 10 Best Free Web Hosting Sites (2018)
Physics determines the speed with which computers can communicate over physical connections and therefore, trying to access a server in the United States while in China might take longer than gaining access to a server within the US while in the US. Large firms set up servers in various strategic locations in the world and make sure that they all have similar data to lower the cost of transmission and improve the experience of the users. This set up is CDN because these servers are edge servers for they bring the company close to the user.
When a browser places a DNS request for a particular domain name handled by a content delivery network, there will be a different procedure than when the domain name has one IP not dealt with by a CDN. The server that handles DNS requests for a domain name inspects incoming requests to determine the server that can manage the application best. The DNS server, at its simplest, does a geographical search basing on the IP address of the DNS resolver and then returns the IP address for the nearby edge server closest to the user. It is not easy to end up with a DNS resolver that is not near the location where you are making the request.
The first step involves getting your request to the closest edge server. You need to remember that firms might optimize their content delivery networks in other ways like redirecting on a server which is relatively affordable to run or an idle server that has a similar capacity. In other cases, the CDN might smartly return the best IP address to handle a particular request.
Edge servers are proxy caches which work similarly to browser caches. When an edge server gets a request, it will first check the cache to ascertain if the content is available. The key to the cache is the entire URL which includes the query string in the browser. If the content is available in the cache and the cache entry is still available, the service of the entry will come directly from the server.
Conversely, if the cache entry expires and the content is not available, the edge server will make a request to retrieve the information from the origin server. The origin server acts as the source of accurate content with the capability of serving all the content available on the CDN. When your edge server receives the response, it stores this content in a cache basing on HTTP of the response.
If you want to know how CDN works, you need to make sure that the Content Delivery Network understands the objects that belong to a particular request by combining the needs of an origin server and a super name registered in the CDN. A super name is the subdomain of a domain a customer controls. The origin server focuses the internet path on the object served from the CDN. You can read more about how CND works here.