What is the working principle of HTTP? How to optimize the HTTP protocol ?, Protocol Working Principle
Optimization made by http1.0
Bandwidth: latency has been solved at this stage: 1. browser blocking: the browser can only connect to the same domain name with four connections at the same time. latency: 2. DNS query: The Browser needs to know the IP address of the target server to establish a connection delay: establish a link: three-way handshake
Differences between http1.0 and http1.1
1 cache processing is different. 1.0 only uses the cache policy for a header file, and 1.1 introduces more
2. Bandwidth Optimization and use of network connections (1.0 is a waste of bandwidth and does not support resumable data transfer. 1.1 only part of the resource can be requested)
3Host Header Processing (1.0 each server is bound with a unique IP address. 1.1 both request messages and response messages support Host header table improvement)
4. Persistent connections (maximum difference)
Http1.0/http1.1 Problems
HTTP1.X re-establishes a connection every time when transmitting data, which undoubtedly increases a lot of Delay Time (mainly in 1.0, which can be solved by 1.1) when data is transmitted in HTTP1.x, all transmitted content is in plain text, and the client and server cannot verify the identity of the other party (you can use https) HTTP1.x during use, the content contained in the header is too large, to some extent, the transmission cost is increased. Although HTTP1.x supports keep-alive, it can compensate for the delay caused by multiple connection creation, however, when the keep-alive is used more frequently, it also brings a lot of performance pressure to the server (for example, requesting a file)
Differences between get and post Methods
Whether the size of the submitted data is limited to obtain a safe value Request. QuereString vs Request. Form security question
Differences between cookie and session
What is cookie?
Cookie technology is a client solution. Cookies are special information sent from the server to the client, which is stored on the client as text files, the client then carries the special information each time it sends a request to the server (the interceptor is required to set the cookie in okhttp)
What is session?
Session is another mechanism for recording the customer status. The difference is that the cookie is stored in the client browser, while the session is saved on the server. When the client browser accesses the server, the server records the client information on the server in some form.
Session: Working Principle
1. Create a session
2. When a session is created, the server generates a unique session id for the session.
3. After the session is created, you can call the session-related method to add content to the session.
4. When the client sends the request again, the session id will be taken. After the server receives the request, it will find the corresponding session id based on the session id.
Differences
Different storage locations have different storage methods (the session can store any content, and the cookie string). The security of the session is different, the session is more secure, the validity period is different, and the cookie is relatively long, if the session is set to-1, when the browser is closed, the pressure on the server will be lost.
HTTPS
It is not a separate protocol, but a conventional HTTP protocol that works on an encrypted connection (SSL/TLS. Encryption by adding Transport Layer Security (TLS) Between TCP and HTTP.
SSL/TLS Protocol
SSL protocol
The transmission speed slows down. More resource consumption.