1. What happens after you enter the URL
(1) the DNS
- 1. Browser DNS cache: first, it reads the last access record from the browser cache
- 2, computer DNS cache: find the cache stored in the system running memory.
- 3, router DNS cache: Some routers also have DNS cache function, the visited domain name will be stored on the router.
- 4. Network operator DNS cache: Internet service providers will also provide DNS services
- 5, recursive query to find a.b.c.d.com
(2) a TCP connection
- First handshake: The browser sends a SYN request to the server telling it that I’m ready
- Second handshake: The server sends to the browser to tell the browser that I’m ready, too, and need to double-check. Syn + ACK
- Third handshake: The browser sends an ACK request to the server
(3) the HTTP request
-
1, the browser sends an HTTP request to the server to request the packet from the server.Copy the code
-
2. Build tools can be used to optimize performance: reduce the number of requests and the time spent on a single request.Copy the code
(4) the HTTP response
- Connection Uses the keep-alive feature
- Content-encoding Compresses resources in gzip mode
- Content-type The MIME type is HTML, and the character set is UTF-8
- Date Indicates the Date of the response
- Server Indicates the WEB Server used
- Transfer-encoding is a data Transfer mechanism provided in HTTP (HTTP/1.1)
(5) Browser parsing and rendering
- 1. Call the HTML parser to parse the HTML into a DOM tree
- 2. Call the CSS parser to parse the CSS into a CSSOM tree
- 3. Call the JS engine to parse the JS code.
- 4. If a DOM node is modified, it is reparsed into a DOM tree
- 5. If the CSS node is modified, it is re-parsed into the CSSOM tree
- DOM + CSSOM = render tree
- The layout has been rendered
(6)TCP four wave disconnection
- First wave: The browser sends the request packet to the server to inform the server that the request packet is sent
- Second wave: The server sends a message to the browser to inform the browser that the request packet is received and the browser waits to disconnect
- Third wave: The server sends the response packet to the browser
- Fourth wave: The browser sends a message to the server to inform the server that the response packet has been received and the connection is disconnected
2. The difference between HTTP and HTTPS
- In terms of security, HTTPS is a secure hypertext protocol, which is more secure than HTTP. Simply put, HTTPS is the HTTP protocol that uses TLS/SSL encryption
- When applying for a certificate, HTTPS requires ca to apply for a certificate
- In terms of transport protocol, HTTP is hypertext transfer protocol and plaintext transfer. HTTPS is a secure SSL encrypted transport protocol
- Connection mode and port, HTTP connection is simple, is stateless, port is 80; HTTPS uses THE SSL protocol for encrypted transmission based on HTTP and uses port 443
3. The difference between POST and GET and other request methods
- Request caching: GET is cached, but POST is not
- Bookmark: GET works, POST doesn’t
- Keep browser history: GET does, POST does not
- Uses: GET is often used to fetch data, post is used to submit data
- Security: POST is more secure than GET
- Request parameters: QueryString is part of the URL get,post can be added,post is placed in the body, unique!
The maximum length of a get request is 1024kb. The maximum length of a post request is not limited
- GET: to request a resource in its entirety.
- POST: Submit a form (common)
- HEAD: requests only the response HEAD
- PUT: (webdav) Upload files (but browsers do not support this method)
- DELETE :(webdav) DELETE
- OPTIONS: Methods that return methods supported by the requested resource