1. What is a cache?
Caching is an example of a space-time change that exists everywhere. By using extra space, we are able to get faster speeds.
First, look at how the user's browser interacts with the server when no Web site is connected to the CDN:
When users browse the website, the browser can save a copy of the pictures or other files in the site locally, so that when the user visits the site again, the browser will not have to download all the files, reducing the amount of download means that the speed of page loading is increased .
But if you add a layer of CDN in the middle, then the user's browser interacts with the server as follows:
The client browser first checks whether a local cache is out of date, if it expires, initiates a request to the CDN Edge node, the CDN Edge node detects whether the cache of user request data expires, and if it does not expire, responds directly to the user request, at which point a complete HTTP request ends If the data has expired , the CDN will also need to send a back-to-source request to the source station to pull up the latest data.
The typical topology diagram for a CDN is as follows:
As you can see, in a scenario where there is a CDN, the data goes through both the client (browser) cache and the CDN Edge node cache two phases
2. The following two phases of the cache are analyzed in detail below:
(1) CDN Cache
What is a CDN cache?
In fact, the CDN cache is equivalent to the train ticket consignment point
8 years ago, there is no fire ticket consignment point, 12306.cn is not to mention. At that time, train tickets can only be purchased in the ticket hall of the railway station, and I live in the small county is not through the train, train tickets to the city's railway station to buy, and from the county to the city, back and forth is a 4-hour drive, is simply a waste of life. Later on, the small county has appeared in the train ticket sales point, you can buy the train directly at the point of sale, convenient a lot of people in the city no longer need to be in a point of hardship line to buy tickets.
CDN can be understood as the distribution of train tickets in each county.,when a user browses a website, the CDN chooses a CDN edge node closest to the user to respond to the user's request, so the request of Hainan Mobile users will not go all the way to Beijing Telecom engine Room server (assuming the source station deployed in Beijing Telecom computer room).
The advantages of CDN are obvious: (1) The CDN node solves the problem of cross-operator and cross-region access, and the access delay is greatly reduced; (2) Most of the requests are completed at the CDN Edge node,CDN plays a role in shunt,reduced load on the source station。 (2) browser (client) caching
Cache (CDN cache, browser (client) cache)