After a long time of front-end development, I would like to summarize the Web Data Interaction methods and Web Data Interaction. In short, the client interacts with the server data and interacts with each other through the HTTP protocol.
First, let's look at the lifecycle of a traditional page request:
1. the browser sends an HTTP request to the web server.
2. The web server parses the request, reads the data storage layer, develops an HTML file, and sends it to the client using an HTTP response.
3. The HTTP response is sent to the browser over the Internet.
4. the browser parses the response of the web server, constructs a DOM tree using the HTML file, and downloads the referenced CSS and JavaScript files.
5. After the CSS resources are downloaded, the browser parses them and applies them to the DOM tree.
6. After the Javascript resources are downloaded, the browser parses and executes them.
The preceding six steps are indispensable for displaying a Web page. The time spent on each step affects the page display speed. Performance Optimization will be discussed later, here we will focus on web interaction methods.
Web data interaction, from the server perspective: There are pull and push, one is pull, and the other is push.
1) Pull is pulling, and the client actively pulls data from the server. The technologies used are Ajax and XSS (Cross-Site Scripting)
2) the push server actively pushes data to the client. The first method is persistent connection, which keeps the connection between the client and the server. If data is updated, the server pushes data to the client. The client accepts the data from the server. It can be understood as long polling. the client and the server must be in a connection state all the time. There is also a pseudo-persistent link. There are two implementation methods, one based on AJAX, which is different from the traditional Ajax method in that the server will block client requests and will not be returned until there is data transmission or timeout. after processing the information returned by the server, the client's JavaScript response handler sends a request again and establishes a new connection.
when the client processes the received data and establishes a connection again, new data may arrive at the server end. The information will be saved by the server end until the client establishes a connection again, the client will retrieve all the information on the current server at a time.