Practical HTTP Compression Distilled

1. How it works

The intercourse between browser and web server.

Compression scheme negotiation:

The web client advertises which compression schemes it supports by including a list of tokens in the HTTP request. For Content-Encoding, the list in a field called Accept-Encoding; for Transfer-Encoding, the field is called TE.
If the server supports one or more compression schemes, the outgoing data may be compressed by one or more methods supported by both parties. If this is the case, the server will add a Content-Encoding or Transfer-Encoding field in the HTTP response with the used schemes, separated by commas.

2. Where to Configure and How to Configure

If your architecture is Apache HTTP Server + Tomcat, configure in Apache, if your web server is Tomcat, configure in Tomcat directly, beware that Apache HTTP Server might have better performance as it coded in C.

Tomcat reference configuration:

<Connector port="8080" maxHttpHeaderSize="8192"
        maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
        enableLookups="false" redirectPort="8443" acceptCount="100"
        connectionTimeout="20000" disableUploadTimeout="true"
        compression="on"
  compressionMinSize="2048"
  noCompressionUserAgents="gozilla, traviata"
  compressableMimeType="text/html,text/xml"/>

3. How to Test

We may need to change HTTP Request Header's Accept-Encoding in browser, for instance, you can install Modify-Headers plugin in Firefox to do this job.

Practical HTTP Compression Distilled_第1张图片

Practical HTTP Compression Distilled_第2张图片

Reference:

[1] http://en.wikipedia.org/wiki/HTTP_compression

[2] http://viralpatel.net/blogs/enable-gzip-compression-in-tomcat/



你可能感兴趣的:(Practical HTTP Compression Distilled)