The compressed transport protocol HTTP SprinBoot

At http protocol, the content may be encoded (i.e. the body section), it can be employed such encoding gzip. So as to achieve the purpose of compression. You can also use other encoding or encryption confuse the content, in order to prevent unauthorized third party to see the contents of the document.

What gzip is that you can do? gzip is a compression method that compresses data to make it smaller, save hard disk resources.
Compression benefits
http compression can be compressed to 40% of the original contents of plain text, thus saving 60% of the data transmission.
Gzip disadvantages of
JPEG files compressed with gzip such is not good enough.
HTTP compression
First, after the browser sends a request (request) to the web server, a compression format such as a support (the gzip), the server will compress the original source, back through the http response (response) message to the web browser, the browser after reception, it is displayed.
HTTP compression process

  1. The browser sends Http request to the Web server, request has Accept-Encoding: gzip, deflate. (Tell the server, the browser supports gzip compression)
  2. Web server upon request, to generate original Response, which has the original Content-Type and Content-Length.
  3. Web server through Gzip, of Response to encode the encoded Content-Type header and has Content-Length (size after compression), and increases the Content-Encoding: gzip Response then sends to the browser.
  4. After the browser to the Response, based on Content-Encoding: gzip for Response to decode. After obtaining the original response, and then displays the web page.
    Unused Gzip:
    Unused Gzip
    open after use Gzip:
    Open after use Gzip:

Using gzip case SpringBoot (Tomcat) for transmission Http (YML) configured as follows:

server:
 compression:
        enabled: true
        mime-types: application/json,application/xml,application/xhtml+xml,text/html,text/xml,text/plain
        min-response-size: 1024

Completion of the addition results in Figure
Before compression protocol
After compression protocol

Guess you like

Origin blog.csdn.net/AdminPwd/article/details/93881146