The steps taken by the browser to access a website

The steps taken by the browser to access a website

The steps taken by the browser to access a website

Chrome searches its own DNS cache

Search the DNS cache of the operating system itself (the browser does not find the cache or the cache has expired)

View the DNS cache information of the Chrome browser (chrome://net-internals/#dns):

Read local HOST file

The browser initiates a DNS system call

Broadband operator server view its own cache

The operator server initiates an iterative DNS resolution request

The operator server returns the result to the operating system kernel and caches it at the same time

The operating system kernel returns the result to the browser

Finally, the browser gets the IP address corresponding to www.imooc.com

After the browser obtains the IP address corresponding to the domain name, it initiates an HTTP "three-way handshake"

After the TCP/IP connection is established, the browser can send HTTP requests to the server. (For example, use the HTTP GET method to request a domain name, the protocol can be HTTP1.0.)

The server receives this request, and after some processing on the backend according to the path parameters, it returns the processed data of a result to the browser. If it is a page of Mukenet, the complete HTML page code will be returned to the browser.

The browser got the complete HTML page code of Mukenet. When parsing and rendering this page, the JS, CSS, and image static resources in it are also HTTP requests that need to go through the above seven main steps. .

The browser renders the page according to the obtained resources, and finally presents a complete page to the user.

Some concepts

1. What is a callback?

Callback is the basis of asynchronous programming. The subsequent logic is encapsulated into the parameters of the starting function, nested layer by layer

2. What is synchronous/asynchronous?

Synchronization refers to a communication method in which the sender sends data and waits for the receiver to send back a response before sending the next data packet.

Asynchronous means: after the sender sends data, it does not wait for the receiver to send back a response, and then sends the next data packet.

3. What is I/O?

Disk writing (in) Disk reading (out)

4. What single thread/multithread?

Only one program can be executed at a time is called single thread

The ability to execute multiple programs at once is called multithreading

5. What is blocking/non-blocking?

Blocking: the previous program has to wait until the execution is complete

Non-blocking: the previous program can be suspended when the previous program is not finished, continue to execute other programs, and wait until it is used before executing

6. What is an event?

A trigger action (such as clicking a button)

7. What is event driven?

An operation caused by a trigger action (for example, a dialog box pops up after clicking a button)

8. What is event-driven callback?

A callback function is registered for an event, but this callback function is not executed immediately. The callback function is called only when the event occurs. This function execution method is called event-driven. This kind of registered callback is an event-driven callback If these callbacks are related to asynchronous I/O (data writing, reading) operations, they can be regarded as callback-based asynchronous I/O, but this kind of callback is driven by events in nodejs

9. What is the event loop?

Event loop Eventloop, if there are a large number of asynchronous operations, some time-consuming I/O operations, and even some timer-controlled delay operations, they must call the corresponding callback function when they are completed to complete some intensive tasks , Without blocking the flow of the entire program execution. At this time, a mechanism is needed to manage it. This mechanism is called the event loop.

All in all: the mechanism for managing a large number of asynchronous operations is called the event loop

Event Loop:

Callback function queue. Functions that execute asynchronously will be pushed into this queue; the queue will be queried cyclically.

Reference: https://cloud.tencent.com/developer/article/1041709 The steps taken by a browser to access a website-Cloud + Community-Tencent Cloud