"Tomcat" Tomcat gzip compressed transfer data

Source: Internet
Author: User

Overview

Because our project's three-dimensional model file is very large, in order to improve the transmission speed, on the server to do zip compression processing is very necessary, can greatly improve the transmission speed.

Configuration

First, you need to modify the mapping mapping relationship configuration for the MIME type of the requested data file in Web. XML, for example, to add a mapping relationship for a binary data file with the suffix named s3m:

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

That is, the. s3m file corresponds to a MIME type of Application/octet-stream. Then edit the Connector element of the Tomcat configuration file Server.xml (the HTTP Connector element is a connection component that is supported for the http/1.1 protocol)

<ConnectorPort= "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"               />

where compression= "on" setting turns on compression,

Compressionminsize= "2048" sets the minimum value of the compressed data, that is, the number of bytes of data must reach 2048 to enable compression.

Compressablemimetype= "Application/octet-stream"

The data that is set to the corresponding MIME type file is compressed, as in the previous mapping we configured in Webxml,

In addition, the Tomcat default setting is to enable file transfer (Sendfile) when the data size reaches 48kb, so we must set the Usesendfile to False when we want to compress more than 48kb of data, depending on the official document interpretation.

After configuring the above information, restart Tomcat to see the effect of releasing data in Iserver.

You can see that the original file is 117k, compressed to 66k, and the browser can extract the data in the appropriate format.

"Tomcat" Tomcat gzip compressed transfer data

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.