JavaScript knowledge about networking point JSON, JSONP

  1. Common HTTP status codes What do you know? Describe the meaning of state codes.
  1. 200, the request succeeds, everything is normal, successful return data
  2. 301, permanent redirection refers to the requested document elsewhere; URI of the new document will be given the header information in response to the positioning. The browser will automatically connect to the new URI.
  3. 302, temporary redirection, the status code indicates that the requested resource has been assigned a new URI, the user desired (present) can be used to access the new URI.
  4. 303, the status code indicates resources due to the presence of another URI corresponding to the resource request, using the GET method should be directed acquisition request
  5. 403, Foribidden server understand this request, but is refusing to perform the task, do not have access
  6. 404, NOT Found requested resource page can not be found, there is no
  7. 503, the server can not respond, due to maintenance or server is overloaded and unable to respond

 

2, the cross-domain experience under what circumstances, to describe a common front-end processing across domains in several ways. And a package jsonp principle

A: The browser core, basic safety features are same-origin policy. Limiting a source text or script loaded from other sources interactively resources, it checks whether homologous when the browser execute a script, the script will be executed only homologous, that is, if different sources across domains.

  1. The principle is to use the script tag from the same origin policy restrictions, and dynamically inserted in a page script, src attribute of the script tag is the address of the backend api interface, and the way to get the front end of the callback function name tells: Jsonp end, a rear end correction will be returned in response to the request, and the data transfer back as a parameter.
  2. CORS :( cross-domain resource sharing) is a resource for the current domain mechanisms are allowed to request access scripts other domains.

When using XMLHttpRequest send the request, the browser if found in violation of the same origin policy will automatically add a request header: origin, after the back-end to determine the response after receiving requests to join a property in Response Headers in: Access-Control- Allow-origin, the value is initiating the request source address, the browser will get the response to determine whether the value of Access-Control-Allow-origin and current of the same address, respond to treatment only after a successful match.

Modern browsers and mobile end support CORS, required under IE 8+

  1. Cross-domain server, proxy server transit

The front end sends a request to the local server, the local server instead of the front end server again sends a request for communication between the server, the local server is a transit point of the role, then the response data returned to the front end.

 

3, Web front-end from what should be to optimize site performance

(1) reducing the volume of the page, loading the network upgrade

The combined static resource compression, (JS / css combined code compression, FIG Sprite)

Caching static resources

CDN load faster using resources

  1. Optimization of page rendering

on the front css, js put back

Lazy loading

Reduce operating dom

 

  1. What browser storage, and describe their differences.

cookie  webStorage(localStorage sessionStorage

Size, expiration time, whether as http request,

 

 

 

  1. Talk about get and post requests

GET requests are active cache browser, POST will not, unless manually.

GET request can only be url encoded, and POST supports multiple encoding.

GET request parameters are intact in the browser history, and the POST parameters will not be retained.

GET request transmitted in the URL parameters are limited length, without the POST.

The data type of the parameter, GET accepts only ASCII characters, but there is no limit POST.

GET more secure than POST, because the parameters directly exposed on the URL, it can not be used to transmit sensitive information.

GET parameters passed via the URL, POST Request body in place.

GET generates a TCP packet; generating the POST two TCP packets. (The GET request, the browser will http header and data sent together, the server response 200 (return data); for the POST, the browser transmits the first header, the server response 100 continue, the browser then transmits data, the server response 200 ok (return data))

 

 

 

6,  the process finished loading the page URL of a page from the input to both what happened?

Loading process:

Browser resolved to the IP address of the domain name according to DNS server

Sending an HTTP request to the IP machine

Server receives, processes and returns the HTTP

The browser's request to obtain the contents of return

The rendering process:

The generated HTML DOM tree structure

According to CSS generated CSSOM

The DOM and CSSOM integrated form RenderTree

According RenderTree start rendering and display

Encountered <script>, executes and blocks rendering

 

 

7, realize you know an array of de-emphasis method (minimum of three)

8 , TCP three-way handshake with the four waving?

A said B: number is I x, I want you requested connection; (first handshake, sending a SYN packet, and then enters the SYN-SEND state)

B of A said after the hearing: My number is y, look forward to your next one, then x + 1 is the number of (means that received number is x, then, that ack = x + 1), agreed to establish a connection. (Second handshake, ACK-SYN packet sent, and then enters the SYN-RCVD state)

A hearing B say agreed to set up a connection to B said: Do you agree with me and confirm the connection (ack = y + 1, ACK = 1, seq = x + 1). (Third handshake, A has entered the ESTABLISHED state)

A B After confirmation of hearing, also enters the ESTABLISHED state.

Four wave is described:

After the conversation with 1.A B, A to end this session, on B said: I want to close the connection (seq = u, FIN = 1). (First wave, A enters FIN-WAIT-1)

2.B said after receiving the message A: Make sure you want to close the connection. (Seq = v, ack = u + 1, ACK = 1) (the second wave, B into the CLOSE-WAIT)

3.A after receiving confirmation of B, and so on for some time, because B might have something to say to him. (A case enter FIN-WAIT-2)

After he finished 4.B to say (but possibly saying), for A, I want to close the connection. (Seq = w, ack = u + 1, FIN = 1, ACK = 1) ( Third Wave)
5.A B after receiving the completion message to said connection: off connection has been received message. (Seq = u + 1, ack = w + 1, ACK = 1) ( the fourth wave, and then enters the A CLOSED) 6.B A confirmation is received later, into the

 

  1. The difference between TCP and UDP

TCP Transmission Control Protocol

UDP User Datagram Protocol

1, TCP connection-oriented (e.g., dial-up connection is established first call); the UDP is connectionless, i.e. without establishing a connection before sending data

2, TCP provides reliable service. In other words, the data transfer connection of TCP, error-free, not lost, not repeat, and arrive out of order; UDP best effort, that does not guarantee reliable delivery

. 3, TCP byte stream and, in fact, the TCP byte stream data as a series of unstructured; for the UDP packets is

UDP no congestion control, and therefore does not cause congestion source host of the network is to reduce the transmission rate (useful for real-time applications such as IP telephony, real-time video conferencing, etc.)
4, each TCP connection can only point to point; UDP support one to one, one to many, and many-to-many interactive communication

5, TCP header of 20 bytes of overhead; small UDP header overhead, only 8 bytes

6, a logical communication channel is TCP reliable full-duplex channel, UDP is unreliable channel

 

  1. What is http

HTTP is shorthand hypertext transfer Protocol (Hypertext Transfer Protocol), which is an application layer protocol TCP / IP protocol for data exchange between process definitions WEB server and WEB browser. The client has connected to the web server, if you want to get a web resource web server, subject to certain communication format, HTTP protocol is used to define the client and the web server communications format.

 

  1. Way to achieve the level of the middle element

 

13, the difference between http and https

To secure data transmission, HTTPS added on the basis of the SSL protocol HTTP, SSL relies on certificates to verify the identity of the server and encrypt communication between the browser and the server.

http hypertext transfer protocol, information is transmitted in the clear, https is encrypted with a security ssl transfer protocol.

Http connection is very simple, is stateless; is constructed by the HTTPS protocol SSL + HTTP encrypted transmission protocol, a network authentication protocol, the http protocol than security.

 

1 4 What rearrangement (reflux) and is redrawn? Under what circumstances would trigger the rearrangement and redrawn.

The browser will parse HTML into DOM, CSS parsed into the CSSOM, DOM and CSSOM merger gave rise to Render Tree. With RenderTree, we know the style for all nodes, and then calculate their size and position on the page, and finally draw the node onto the page.

Return: process when the size of the Render Tree in part or all of the elements, structures, or certain properties change, the browser re-render some or all of the document referred to reflux.

First page rendering

Browser window size changes

Change size or position of the element

Changes in element content (text number or picture size, etc.)

Change the font size of the element

Add or remove visible DOM element

When the page, change the style element does not affect its position in the flow of the document (for example: color, background-color, visibility, etc.), the browser will be given to the new style elements and redraw it, a process called re painted.

Avoid frequent pattern of operations, the best one-time override the style, or a one-time change class, avoid frequent operation dom, the elements with complex animations using absolute positioning, so that it flows out of the document, otherwise it will cause the parent element and subsequent elements frequently reflux.

Published 19 original articles · won praise 58 · views 50000 +

Guess you like

Origin blog.csdn.net/cyg_l02/article/details/84945257