Front-end interview questions [HTTP/HTML/browser]

1. Talk about http and https

http: Hypertext Transfer Protocol, https: Hypertext Transfer Security Protocol
difference:

  1. HTTP transmission data is unencrypted and is transmitted in plain text; https uses SSL protocol to encrypt data;
  2. The https protocol requires a ca certificate, which is expensive;
  3. The http port number is 80, and the https port number is 443;
  4. Http is a stateless connection, and both use tcp's three-way handshake to connect.

2. Https how to encrypt transmission

3. The difference between http1.0 and http2.0, what about 2.0 and 3.0

4. TCP three-way handshake

  1. c sends a packet to s and waits for s to confirm;
  2. After receiving the package, s confirms and then sends a package to c to wait for confirmation;
  3. After c receives the package, it confirms and then sends the package to s, and then both parties are in the state of sending or receiving.

5. TCP and UDP

  1. tcp is connection-oriented, udp does not need to establish a connection first;
  2. TCP is byte-oriented, and UDP is packet-oriented;
  3. TCP is reliable.

6.Websocket

  1. Websocket is a protocol in H5 that supports persistent connections;
  2. Based on the http protocol, multiple requests can be sent and multiple responses received;
  3. WebSocket makes data exchange between client and server easier, allowing the server to actively push data to the client. In the WebSocket API, the browser and the server only need to complete a handshake, and a persistent connection can be established between the two, and two-way data transmission can be performed.

7. After entering a url

  1. DNS resolves the domain name and gets the real IP;
  2. Establish a connection, TCP three-way handshake;
  3. Take the data and render the page;
  4. Wave four times.

8. How to render the page?

  1. HTML forms a DOM tree, and css forms a css structure;
  2. Both of them form a render tree rendering tree;
  3. Calculate the page layout;
  4. The UI engine renders the page.

9. HTTP request

insert image description here

10. Status code

insert image description here

  1. 200 request successful
  2. 400 The syntax of the client's request is incorrect and the server cannot understand it
  3. 401 request requires user authentication
  4. 403 The server understands the client's request, but refuses to execute the request
  5. 404 The server cannot find the resource (web page) according to the client's request
  6. 500 Internal server error, unable to complete the request

11.fetch sends two requests

The reason why two requests are sent is because we use cross-domain requests with preflight (except get, post, head requests). This request will send a preflight request of type OPTIONS before sending the actual request. The preflight request will check whether the server supports the cross-domain resources required by our real request, and the real request will only be sent if the resource meets the conditions. For example, if we add the authorization item in the request header, then Access-Control-Allow-Headers needs to be placed in the server response header, and its value must contain authorization, otherwise the OPTIONS pre-check will fail, resulting in no real request.

12. The difference between cookie, session storage and local storage

  1. Cookies are passed back and forth between the browser and the server, sessionStorage, localStorage: only saved in the client (browser), and do not participate in server communication;
  2. The cookie storage size is smaller, otherwise it will cause performance problems;
  3. cookie: determine whether the user has logged in to the website, so as to automatically log in next time or remember the password; save event information; sessionStorage: one-time login for sensitive accounts, and more for single pages; localStorage: for long-term login, suitable for long-term storage local data;
  4. The cookie validity period is generally set by the server; localstorage is generally permanent, unless you manually delete the reomveItem, or clear the browsing history; session storage generally becomes invalid when the page is closed.

13.webworker

14. Request header content

15. Cookie

16. XSS attack and CRSF attack

17. TCP congestion control

18. Cross domain issues

19.session and cookie

20. HTML semantic tags

21. viewport and mobile terminal layout

22. Event flow addEventListener

23. Strong caching and negotiation caching

24. The difference between GET and POST

25. Website Performance

26. New Features of H5

27.meta and Doctype

Guess you like

Origin blog.csdn.net/qq_46056318/article/details/127720138