Home Common Problem What happens when the browser enters the address

What happens when the browser enters the address

Oct 24, 2019 pm 05:24 PM
Browser

What happens when the browser enters the address

What happens after entering the address in the browser

The browser is a tool for us to surf the Internet. We usually watch videos and check information. Internet surfing is inseparable from it, so do you know what the browser does after you hit the Enter key in the browser address bar? Today I will share with you the work behind the browser.

Step 1: Enter the domain name in the browser

For example, enter: www.php.cn

What happens when the browser enters the address

Step 2: The browser searches for the IP address of the domain name

The browser will parse the entered domain name into the corresponding IP. The process is as follows :

1. Search the browser cache: Because browsers generally cache DNS records for a period of time, different browsers may have different times, usually ranging from 2 to 30 minutes. The browser will search for these caches. If If there is a cache, return the IP directly, otherwise take the next step.

2. Search the system cache: After the IP is not found in the browser cache, the browser will make a system call (gethostbyname in Windows) to search for the hosts file of the local machine. If found, the IP will be returned directly, otherwise Next step.

3. Search the router cache: If the query in steps 1 and 2 fails, you need to use the network. The router generally has its own DNS cache. Send the previous request to the router to find the ISP service provider cache DNS. server, if the IP is found, it will be returned directly, if not, continue to search.

4. Recursive query: If the above steps cannot be found, the ISP's DNS server will perform a recursive query. The so-called recursive query means that if the local domain name server queried by the host does not know the IP address of the queried domain name , then the local domain name server will continue to send query request messages to other root domain name servers as a DNS client, instead of letting the host perform the next query on its own. (The local domain name server address is obtained through the DHPC protocol, and DHPC is responsible for allocating IP addresses)

5. Iterative query: The local domain name server uses iterative query, and it first queries a root domain name server. The local domain name server's query to the root domain name server generally uses iterative query. The so-called iterative query means that after the root domain name server receives the query request message sent by the local domain name server, it either tells the local domain name server which domain name server it should query next, and then the local domain name server performs subsequent queries on its own. (rather than replacing the local name server for subsequent queries).

Step 3: The browser establishes a TCP connection with the target server

1. After the host browser obtains the IP address of the target server through DNS resolution, it establishes a TCP connection with the server. TCP connection.

2.TCP 3-way handshake connection: the client where the browser is located sends a connection request message to the server (SYN flag is 1); after receiving the message, the server agrees to establish the connection and sends a confirmation message to the client (SYN and ACK flag bits are both 1); after the client receives the confirmation message, it sends a message to the server again to confirm that the confirmation message has been received; here the TCP connection between the client and the server is established and the process begins communication.

Step 4: The browser sends a request through the http protocol

The browser initiates an HTTP-GET method message request to the host. The request contains the accessed URL, that is, http://www.php.cn/, KeepAlive, long connection, as well as User-Agent user browser operating system information, encoding, etc. It is worth mentioning the Accept-Encoding and Cookies items. Accept-Encoding generally uses gzip to transmit html files after compression. If Cookies is accessed for the first time, the server will be prompted to establish user cache information. If not, you can use the corresponding key value of Cookies to find the corresponding cache. The cache stores the user name, password and some user settings.

Step 5: Some services will make permanent redirect responses

For large websites with multiple host sites, load balancing or importing traffic can improve SEO rankings , often not directly returning the requested page, but redirecting. The returned status code is not 200OK, but a redirection code starting with 301,302. After the browser obtains the redirection response, it finds the redirection address in the Location item in the response message, and the browser can access it again in the first step. .

The role of redirection: Redirection is for load balancing or importing traffic to improve SEO rankings. Using a front-end server to accept requests and then loading them on different hosts can greatly improve the site's concurrent business processing capabilities; redirection can also concentrate access from multiple domain names to one site; because baidu.com, www.baidu. com will be considered by search engines to be two websites, and the number of links to each will be reduced, thereby lowering the ranking. Permanent redirection will associate the two addresses, and search engines will consider them to be the same website, thus improving the ranking.

Step 6: The browser tracks the redirect address

When the browser knows the final access address after the redirection, it resends an http request and sends the content Same as above.

Step 7: The server processes the request

The server receives the get request, then processes and returns a response.

Step 8: The server sends an HTML response

Return status code 200 OK, indicating that the server can respond to the request and return the message, because the Content-type in the header For "text/html", the browser renders it as HTML instead of downloading the file.

Step 9: Release the TCP connection

1. The host where the browser is located sends a connection release message to the server, and then stops sending data;

2. After receiving the release message, the server sends a confirmation message, and then sends the untransmitted data on the server;

3. After the server data transmission is completed, it sends a connection release message to the client;

4. After receiving the message, the client sends a confirmation, and then waits for a period of time before releasing the TCP connection;

Step 10: The browser displays the page

When the browser has not fully accepted all the HTML documents, it has already started to display this page. The browser receives the returned data packet and renders the corresponding data according to the browser's rendering mechanism. The rendered data performs corresponding page rendering and footstep interaction.

Step 11: The browser sends and obtains other content embedded in HTML

For example, some style files, image URLs, js file URLs, etc., the browser will Re-send the request through these URLs. The request process is still a process similar to HTML reading, querying the domain name, sending the request, redirecting, etc. However, these static files can be cached in the browser. Sometimes these files are accessed directly from the cache without going through the server. Some websites also use third-party CDNs to host these static files.

The above is the detailed content of What happens when the browser enters the address. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1225
24
How to register an account on Ouyi Exchange Ouyi Exchange Registration Tutorial How to register an account on Ouyi Exchange Ouyi Exchange Registration Tutorial Apr 24, 2025 pm 02:06 PM

The steps to register an Ouyi account are as follows: 1. Prepare a valid email or mobile phone number and stabilize the network. 2. Visit Ouyi’s official website. 3. Enter the registration page. 4. Select email or mobile phone number to register and fill in the information. 5. Obtain and fill in the verification code. 6. Agree to the user agreement. 7. Complete registration and log in, carry out KYC and set up security measures.

What is the reason why the browser does not respond after the WebSocket server returns 401? How to solve it? What is the reason why the browser does not respond after the WebSocket server returns 401? How to solve it? Apr 19, 2025 pm 02:21 PM

The browser's unresponsive method after the WebSocket server returns 401. When using Netty to develop a WebSocket server, you often encounter the need to verify the token. �...

How to correctly generate and display the WeChat applet with parameters QR codes in Java? How to correctly generate and display the WeChat applet with parameters QR codes in Java? Apr 19, 2025 pm 04:48 PM

Generating a WeChat applet QR code with parameters in Java and displaying it on an HTML page is a common requirement. This article will discuss in detail how to use J...

Can JWT implement dynamic permission changes? What is the difference from the Session mechanism? Can JWT implement dynamic permission changes? What is the difference from the Session mechanism? Apr 19, 2025 pm 06:12 PM

Confusion and answers about JWT and Session Many beginners are often confused about their nature and applicable scenarios when learning JWT and Session. This article will revolve around J...

Why can't JavaScript directly obtain hardware information on the user's computer? Why can't JavaScript directly obtain hardware information on the user's computer? Apr 19, 2025 pm 08:15 PM

Discussion on the reasons why JavaScript cannot obtain user computer hardware information In daily programming, many developers will be curious about why JavaScript cannot be directly obtained...

Binance download link Binance download path Binance download link Binance download path Apr 24, 2025 pm 02:12 PM

To safely download the Binance APP, you need to go through the official channels: 1. Visit the Binance official website, 2. Find and click the APP download portal, 3. Choose to scan the QR code, app store, or directly download the APK file to download to ensure that the link and developer information are authentic, and enable two-factor verification to protect the security of the account.

What to do if the USDT transfer address is incorrect? Guide for beginners What to do if the USDT transfer address is incorrect? Guide for beginners Apr 21, 2025 pm 12:12 PM

After the USDT transfer address is incorrect, first confirm that the transfer has occurred, and then take measures according to the error type. 1. Confirm the transfer: view the transaction history, obtain and query the transaction hash value on the blockchain browser. 2. Take measures: If the address does not exist, wait for the funds to be returned or contact customer service; if it is an invalid address, contact customer service and seek professional help; if it is transferred to someone else, try to contact the payee or seek legal help.

What is on-chain transaction? What are the global transactions? What is on-chain transaction? What are the global transactions? Apr 22, 2025 am 10:06 AM

EU MiCA compliance certification, covering 50 fiat currency channels, cold storage ratio 95%, and zero security incident records. The US SEC licensed platform has convenient direct purchase of fiat currency, a ratio of 98% cold storage, institutional-level liquidity, supports large-scale OTC and custom orders, and multi-level clearing protection.