http-cdn
Overview
A content delivery network (CDN) is a group of servers set up in different locations worldwide to provide web content over a wide geographic area much faster.
CDN, also known as “distribution networks,” offers several points of presence (PoP) outside the origin server. This enables websites to better manage traffic by handling user requests more quickly, providing an overall better experience.
In short, you’re using a CDN every time you visit a high-traffic site such as Amazon or catch up with your friends on Facebook. Their data centers keep allows to bring such content much more quickly regardless of the geographic location of individual users or the main website server.
By spreading the delivery systems out over a large area, websites can reduce bandwidth consumption and page load times, shaving precious seconds off the time it takes to handle multiple user requests.
CND Inside
how it works
When the browser makes a DNS request for a domain name that is handled by a CDN
, there is a slightly different process than with small, one-IP sites. The server handling DNS requests for the domain name looks at the incoming request to determine the best set of servers to handle it. At it’s simplest, the DNS server does a geographic lookup based on the DNS resolver’s IP address and then returns an IP address for an edge server that is physically closest to that area
.
Edge servers are proxy caches that work in a manner similar to the browser caches. When a request comes into an edge server, it first checks the cache to see if the content is present. The cache key is the entire URL including query string (just like in a browser). If the content is in cache and the cache entry hasn’t expired, then the content is served directly from the edge server.
If, on the other hand, the content is not in the cache or the cache entry has expired, then the edge server makes a request to the origin server to retrieve the information. The origin server is the source of truth for content and is capable of serving all of the content that is available on the CDN. When the edge server receives the response from the origin server, it stores the content in cache based on the HTTP headers of the response
why needs it?
To begin, CDNs are networks of servers strategically distributed in many parts of the globe. Each server acts as a content delivery tool and they primarily function to reduce latency—the period it takes for a web page to load in entirety. In other words, CDNs improve one’s browsing experience because they speed things up
.
For example, let’s assume your site is hosted by a data center in Washington. When you don’t have a CDN, each of your visitors will have to download all of your website files from Washington. This isn’t a problem if your site visitors are from Vancouver, Pennsylvania, or Maryland. But what if they’re from Australia? Data does travel quickly, but that’s still 9,756 miles!
Simply put, no matter how updated and inventive your hardware is, distance is bound to delay your website’s loading speed for your users who are in distant parts of the world. This is exactly why websites that get good traffic need the technology. CDNs are one solution to retain customers. When you run a business, content delivery is an activity you can’t overlook. Otherwise, you’re only going to lose money.
What Can a CDN Do?
Modern CDNs can handle numerous IT tasks, helping you to:
- Improve page load speed
- Handle high traffic loads
- Block spammers, scrapers and other bad bots
- Localize coverage without the cost
- Reduce bandwidth consumption
- Load balance between multiple servers
- Protect your website from DDoS attacks
- Secure your application
- And more
FAQ
Which is CNAME
A canonical name record (CNAME) is used in the Domain Name System (DNS) to create an alias from one domain name to another domain name
, usually used for CND network, you may need to create alias of your origin server at DNS provider
, so taht dns lookup for your domain returns CNAME(provided by CDN vendor)
, then dns lookup for CNAME will get closer
IP(edge server) provided CND provider.
1 | $ nslookup |
How to Enable CDN for your website?
- login your CDN vendor
- enable CDN for your website in CDN console,
enter webiste domain and Origin server ip
then CDN network can get content from it for eachfirst request.
update DNS name server in DNS provider
with name server provider by CDN vendor, so tahtdns lookup for your domain will the edge server
.
OrAdd CNAME(provided by CDN vendor) in your DNS provider
to redirect dns lookup to edge server.