[TOMCAT] Tomcat gzip compression transmission data, tomcatgzip compression transmission

Source: Internet
Author: User

[TOMCAT] Tomcat gzip compression transmission data, tomcatgzip compression transmission
Overview

Because the 3D model file of our project is very large, in order to improve the transmission speed, it is necessary to perform zip compression on the server side, which can greatly improve the transmission speed.

Configuration

First, modify the mime ing configuration of the mime type of the data file requested in web. xml. For example, add a ing relationship to the binary data file with the suffix s3m:

<mime-mapping>        <extension>s3m</extension>        <mime-type>application/octet-stream</mime-type></mime-mapping>

That is, the mime type of the. s3m file is application/octet-stream. Edit the Connector element of the tomcat configuration file server. xml (the HTTP Connector element is a connection component supported by http/1.1)

<Connector port="8090"               protocol="HTTP/1.1"                             connectionTimeout="20000"               redirectPort="8453"               executor="tomcatThreadPool"               enableLookups="false"                URIEncoding="utf-8"               compression="on"               compressionMinSize="2048"               useSendfile = "false"               compressableMimeType="application/octet-stream"               />

Compression = "on" sets enable compression,

CompressionMinSize = "2048" sets the minimum value of the compressed data, that is, compression is enabled only when the number of bytes of the data must reach 2048,

CompressableMimeType = "application/octet-stream"

Set it to the data of the corresponding mime-type file for compression, as we previously configured in webxml,

In addition, the default setting of tomcat is to enable file transfer (sendfile) when the data size reaches 48 KB. Therefore, to compress data larger than 48 KB, we must set useSendfile to false, for more information, see the official documentation.

After the above information is configured, restart tomcat to check the effect of data publishing in iserver.

 

You can see that the original file is 117 KB, and the compressed file is changed to 66 KB. the browser can decompress the data in the corresponding format.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.