HTTP/1.1, HTTP/2 are TCP-based, and HTTP/3 is a UDP-based.
When a client sends a request to the server, the server sends a response to it.
The server does not preserve the state of the client.
Stateless can easily change the response server.
Stateful protocol get communication problem when server change. However, Stateless protocol, client-server communication continues even if the server changes.
That's reason why stateless protocol is easy to expand server.
A simple service introduction screen can be designed as stateless. For services that require various functions, it is recommended to use cookies, sessions, and tokens to maintain state.
If Client-Server keep the connection, the server cost continues to increase. So, through connectionlessness, HTTP only keeps the connection when it actual request, and closes the TCP/IP connection after giving back a response.
However, when there is a lot of traffic and a large-scale service is operated, Connectionless is limits.
It is inefficient to disconnect and reconnect repeatedly when many elements such as HTML, CSS, and Javascript need to be response.
This problem can be solved with Persistent Connectionless.
HTTP messages can be divided into header and body.
HTTP Body contains data message and data.
The part that carries data is called Payload.
HTTP Header is used to contain additional information required for HTTP transmission.
Server: Apache/2.2.22
Server: nginx
Date: Tue, 15 Nov 1994 08:12:31 GMT
When the response result is 3xx, if there is a Location option in the Header, it redirects to the location address.
201(created): The Location value is the resource URI generated by the request.
Allow: GET, HEAD, PUT
Retry-After: Fri, 31 Dec 2020 23:59:59 GMT(날짜 표기)
Client can request the language what they wants from the server.
In general, if there is no setting, English is set as the default language.
When the client sets Accept-Language KO, the server responds in Korean.
If the language is not supported, it responds in the language stored in the server.
Priority can be specified from 1 to 0.
Accept-Language: ko-KR;q=0.9, en-US;q=0.8;
A cache is a special storage space for temporary files that makes a device, browser, or app run faster and more efficiently.
(it is temporary storage, the validity period is short.)
The validation header uses Last-Modified to know the cache modification time. Check when the data was last modified and update the cache if there is a difference compared to the stored cache time.
Proxy means that a client can communicate between servers on a surrogate basis.
(A server that performs a relay function is called a proxy server.)
It has advantages such as traffic distribution.
If the distance between the client and the main server is far, the data fetching speed is slow, but if you use a proxy server in the middle, you can get it at a fast speed.
Cache-Control: public
The response is stored in a public cache.
Cache-Control: private
The response is stored in a private cache.
Cache-Control: maxage
Maxage that only applies to the proxy cache.
Age:60 (HTTP Header)
The length of time the proxy cache stays after a response from the origin server
Cache-Control: no-cache
You can cache the data. However, it should always be validated on the main server.
Cache-Control: no-store
The data should not be stored as it contains sensitive information.
Cache-Control: must-revalidate
When the cache is reused after expiration of the period, it must be verified by the main server.
If you want a clear cache invalidation response, you can use no-cache, no-store, or must-revalidate options.
If the proxy cache server loses network connection with the main server, no-cache returns the previous data and responds with 200OK.
However, when using must-revalidate. Proxy server always verified by the main server. If Proxy server cannot access to Main server, It will show 504 Gateway Timeout.
Therefore, you must use must-revalidate. when make problems using old data.