1. First, enter the URL in the browser
2. The browser finds the IP address of the domain name
The DNS lookup process is as follows: Browser cache – The browser caches DNS records for a period of time. Interestingly, the operating system does not tell the browser when to store DNS records, so that different browsers store a self-fixed time (ranging from 2 minutes to 30 minutes). System cache – If the required records are not found in the browser cache, the browser makes a system call (gethostbyname in Windows). This will get the records in the system cache. Router caching – Next, the previous query request is sent to the router, which generally has its own DNS cache. ISP DNS Cache – The next check is the ISP cache DNS server. The corresponding cache record can be found in this general. Recursive search – Your ISP's DNS server starts with a recursive search with a domain name server, from a. com top-level domain name server to a Facebook domain name server. In the general DNS server cache there will be domain names in the. com domain name server, so the match process to the top level server is not so necessary.the solution when DNS returns multiple IPs:1. Load balancer: A hardware device that listens on a specific IP address and forwards network requests to a clustered server. Some large sites typically use this expensive, high-performance load balancer. 2. Geo-DNS: Improve scalability by mapping domain names to multiple different IP addresses, depending on the geographic location of the user. Such a different server is not able to update the synchronization state, but it is good to map the static content. For example, input google.com return to www.google.com.hk in China, return to www.google.fr in France3.Anycast: Is a routing technology that maps multiple physical hosts to an IP address. In the ointment, anycast and the TCP protocol are not well adapted. most DNS servers use anycast to obtain efficient, low-latency DNS lookups.
3. The browser sends an HTTP request to the Web server
GEThttp://facebook.com/http/1.1Accept: Application/x-ms-application,image/jpeg, Application/xaml+xml, [...]user-agent: mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; [...]accept-encoding: gzip, deflateConnection: Keep-alive Host:facebook.comCookies: datr=1265876274-[...]; Locale=en_us; Lsd=ww[...]; C_user=2101[...] GET This request defines: 1) The URL to read: "http://facebook.com/". 2) browser definition (user-agent header) 3) It wants to accept what type of corresponding (accept and accept-encoding header) 4) The connection header requires the server to not close the TCP connection in order to request it behind. 5) Cookies are key values that match the status of a website. This allows cookies to store login usernames, server-assigned passwords, and some user settings. Cookies are stored in the client computer as text documents and sent to the server each time it is requested.
4. Permanent REDIRECT response for Facebook serviceshttp/1.1301Moved permanentlycache-control:private, No-store, No-cache, must-revalidate,post-check=0, pre-check=0 Expires:sat, 01 Jan 00:00:00 gmtlocation:http://www.facebook.com/p3p:cp= "DSP law" Pragma:no-cache set-cookie:made_write_conn= Deleted expires=thu,12-feb-2009 05:09:50 GMT; path=/; domain=.facebook.com; httponlycontent-type:text/html; Charset=utf-8 x-cnection:close date:fri,12 05:09:51 GMT content-length:0 Server responds to the browser with a 301 permanent redirect so that the browser accesses the HTTP ://www.facebook.com/"rather than" http://facebook.com/". Why does the server have to redirect rather than directly send the Web content that the user wants to see? cause I: It's about the search engine rankings. You see, if a page has two addresses, like http://www.igoro.com/and http://igoro.com/, the search engine will think of them as two sites, resulting in fewer search links and less rankings. Cause II: Using a different address can result in poor cache friendliness. When a page has several names, it may appear several times in the cache.
5. Browser tracing REDIRECT Address
Now, the browser knows that "http://www.facebook.com/" is the correct address to access, so it sends another fetch request: Get http://www.facebook.com/HTTP/1.1 Accept: Application/x-ms-application, Image/jpeg, application/xaml+xml,[...] Accept-language:en-us user-agent:mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; [...] Accept-encoding:gzip,deflate connection:keep-alive cookie:lsd=xw[...]; C_user=21[...]; X-referer=[...] Host:www.facebook.com This is why when you enter http://facebook.com/in the browser, you are redirected to http://www.facebook.com/.
6. Server "Processing" RequestsThe Web server software (like IIS and Apache) receives an HTTP request and then1) Perform related request processing, may read or update some data, and store the data on the server.request processing is a program that can read requests and generate HTML to respond (like Asp.net,php,ruby ...). 2) demand processing generates an HTML response . Requirements processing can be stored in a file hierarchy that maps the site address structure. Like http://example.com/folder1/page1.aspx this address will map/httpdocs/folder1/page1.aspx this file. The Web server software can be set as the address manual for the corresponding request processing, so that the Page1.aspx publishing address can be http://example.com/folder1/page1. The server to distinguish the request of different customers, through the socket, each time the service period received a client sent a connection request, the server and the customer to create a socket, guarantee the channel of data transmission, HTTP request can be transmitted in this channel.
7. The server sends back an HTML response
http/1.1 $OkCache-control: Private, No-store, No-cache,must-revalidate, post-check=0, pre-check=0 Expires:sat, Jan2000 00:00:00 GMT p3p:cp= "DS P Law "Pragma:no-cachecontent-encoding: gzipcontent-type:text/html; Charset=utf-8 x-cnection:close transfer-encoding:chunked Date:fri, 09:05:55gmt [email protected][...] The entire response size is 35kB, most of which is transferred as BLOB type after finishing. Content includes: 1) the content encoding header tells the browser that the entire response body is compressed with the GZIP algorithm. After extracting the BLOB block, you can see the expected html:2) whether the page is cached or not, and if so, what cookies to set (not in the previous response) and privacy information. 3) Set Content-type to "text/html" so that the browser renders the response in HTML instead of downloading it as a file.
8. The browser starts to display HTMLWhen the browser does not fully accept the entire HTML document, it has already started to display this page:
9. The browser sends the object embedded in the HTMLWhen the browser displays HTML, it will notice the need to get a label for other address content. At this point, the browser sends a FETCH request to retrieve the files. Here are a few URLs we need to get back when we visit facebook.com:
Imagehttp://upload.chinaz.com/2013/0228/1362014211396.gifhttp://upload.chinaz.com//...
CSS Style SheetsHttp://static.ak.fbcdn.net/rsrc.php/z448Z/hash/2plh8s4n.csshttp://static.ak.fbcdn.net/rsrc.php/zANE1/hash/cvtutcee.css ...
JavaScript FilesHttp://static.ak.fbcdn.net/rsrc.php/zEMOA/hash/c8yzb6ub.jshttp://static.ak.fbcdn.net/rsrc.php/z6R9L/hash/cq2lgbs8.js ... These addresses are going through a process similar to HTML reading. So the browser will find these domain names in DNS, send requests, redirect, etc... But not likeDynamic PagesThatStatic Fileswill allow the browser to cache it. Some files may not need to be communicated to the server and read directly from the cache. The server's response contains the term information for static file retention, so the browser knows how long to cache them.
10. The browser sends an asynchronous (AJAX) RequestTake the Facebook chat feature as an example, and it will keep in touch with the server to update your shiny gray friend status in a timely fashion. In order to update the status of these avatar-lit friends, the JavaScript code executed in the browser sends an asynchronous request to the server. This asynchronous request is sent to a specific address, http://www.facebook.com/ajax/chat/buddy_list.php, to get information about which online status your friends are in. When you bring up this pattern, you have to talk about "AJAX"-"Asynchronous JavaScript and XML," although the reason why the server responds in XML format is casualgirlfriend. For example, for an asynchronous request, Facebook will return some JavaScript code snippets. Among other fiddler, this tool allows you to see the asynchronous requests sent by the browser. In fact, you can not only passively as a spectator of these requests, but also proactively make changes and resend them. Ajax requests are so easy to be blindfolded that it's really frustrating for those scoring online game developers. The Facebook Chat feature provides an interesting case for Ajax: Pushing data from the server side to the client. Because HTTP is a request-response protocol, the chat server cannot send new messages to customers. Instead, the client has to poll the server every few seconds to see if it has any new messages called "polling."
How to jump to the specified server after entering the URL in the browser