You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Michael <sg...@gmx.net> on 2009/04/04 16:56:54 UTC
HTTP Connector GZIP compression
Hi folks,
recently I came upon the built-in compression of Tomcat. After reading
the docs I turned compression on and set html, javascript and css to
compress.
I am on tomcat 5.5.27. Unfortunately compression worked arbitrary,
worked on html only and worked even when I turned it off.
I scanned the source code and did not notice something odd.
Is there any known issue with this? How can I make sure that the
compression works really at my command. I could use alternative
mod_deflate but I'd rather want Tomcat do it.
Thanks,
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: HTTP Connector GZIP compression
Posted by Michael <sg...@gmx.net>.
Caldarale, Charles R wrote:
>> From: Michael [mailto:sgfan@gmx.net]
>> Subject: Re: HTTP Connector GZIP compression
>> Checked, the server.xml remains the same. I did not alter
>> It except the invalid attribute. The same happens for CSS too.
>
> Did you restart Tomcat after making the change? Are you sure you're actually using the server.xml you think you are?
Yes, I am absolutely sure.
>> The simple reason is that I have disabled compression
>> completely and the uncompressed size is 72 726 bytes.
>
> No, that's the size of the .jsp file - that has little relevance to the size of the generated HTML.
Right, but my jsp contains lorem ipsum only, so plain text only. But
this makes absolutely sense since JSP is dynamic and the final size is
not known before is it is send to the user.
BUT:
I created a minimal server.xml ans started tomcat with the Tomcat
service under Windows.
This is the new server.xml: http://www.pastie.org/437744
Additionally, I have created several files which should or should not be
compressed, threshold 40 KiB, which should *always* work with all non
dynamic content.
This is the output of Firefox with Fiddler:
http://home.htw-berlin.de/~s0525102/fiddler.log (plain text).
To be perfectly honest, only JSP compression seems to be predictable,
the rest aboslutely not. What's wrong here.
Thanks again,
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: HTTP Connector GZIP compression
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Michael [mailto:sgfan@gmx.net]
> Subject: Re: HTTP Connector GZIP compression
>
> What is the rationale for? Is there a good reason to
> compress anyway?
The size is unknown until the last chunk is generated, so no threshold can be applied. Since chunked encoding usually involves larger outputs, the appropriate thing to do is compress.
> Checked, the server.xml remains the same. I did not alter
> It except the invalid attribute. The same happens for CSS too.
Did you restart Tomcat after making the change? Are you sure you're actually using the server.xml you think you are?
> The simple reason is that I have disabled compression
> completely and the uncompressed size is 72 726 bytes.
No, that's the size of the .jsp file - that has little relevance to the size of the generated HTML.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
Re: HTTP Connector GZIP compression
Posted by Michael <sg...@gmx.net>.
Caldarale, Charles R wrote:
>> From: Michael [mailto:sgfan@gmx.net]
>> Subject: Re: HTTP Connector GZIP compression
>>
>> 1. lorem.jsp: 72 726 bytes
>> 2. prototype.js: 134.057 bytes
>>
>> According to the above setting only the JS file should be compressed.
>
> No; response from the .jsp will also be compressed if the return type is html - which it almost always is for JSPs.
Well, I was not refering to the mime type but to the file size. I set
the threshold to 80 000 bytes. No compression should happen below 80 000
bytes. Did I missunderstand something here?
>> HTTP/1.1 200 OK
>> Content-Type: text/html;charset=UTF-8
>> Transfer-Encoding: chunked
>> Content-Encoding: gzip
>
>> Regarding number 1: this is compressed although I set
>> threshold to 80000 bytes
>
> Note the Transfer-Encoding of chunked along with this sentence from the doc:
>
> "If the content-length is not known and compression is set to 'on' or more aggressive, the output will also be compressed."
Ok, understood. What is the rationale for? Is there a good reason to
compress anyway?
>> HTTP/1.1 200 OK
>> Content-Type: text/javascript
>> Content-Length: 134057
>>
>> Regarding number 2: the Javascript ist not compressed!
>
> That does seem to be a problem; check your server.xml again now that you've removed the undefined attribute.
Checked, the server.xml remains the same. I did not alter it except the
invalid attribute. The same happens for CSS too.
>> No I turn compression off:
>>
>> # Result Protocol Host URL Body
>> 0 200 HTTP localhost:8080 /java-demo/lorem.jsp 19665
>>
>> Caching Content-Type Process
>> text/html;charset=UTF-8 firefox:500
>>
>> lorem.jsp still compressed: WTF
>
> Why do you think the output of lorem.jsp is compressed this time?
The simple reason is that I have disabled compression completely and the
uncompressed size is 72 726 bytes. But 19 665 bytes have been sent over
the wire which means I has beeen compressed anyway.
Thanks again,
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: HTTP Connector GZIP compression
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Michael [mailto:sgfan@gmx.net]
> Subject: Re: HTTP Connector GZIP compression
>
> 1. lorem.jsp: 72 726 bytes
> 2. prototype.js: 134.057 bytes
>
> According to the above setting only the JS file should be compressed.
No; response from the .jsp will also be compressed if the return type is html - which it almost always is for JSPs.
> HTTP/1.1 200 OK
> Content-Type: text/html;charset=UTF-8
> Transfer-Encoding: chunked
> Content-Encoding: gzip
> Regarding number 1: this is compressed although I set
> threshold to 80000 bytes
Note the Transfer-Encoding of chunked along with this sentence from the doc:
"If the content-length is not known and compression is set to 'on' or more aggressive, the output will also be compressed."
> HTTP/1.1 200 OK
> Content-Type: text/javascript
> Content-Length: 134057
>
> Regarding number 2: the Javascript ist not compressed!
That does seem to be a problem; check your server.xml again now that you've removed the undefined attribute.
> No I turn compression off:
>
> # Result Protocol Host URL Body
> 0 200 HTTP localhost:8080 /java-demo/lorem.jsp 19665
>
> Caching Content-Type Process
> text/html;charset=UTF-8 firefox:500
>
> lorem.jsp still compressed: WTF
Why do you think the output of lorem.jsp is compressed this time?
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
Re: HTTP Connector GZIP compression
Posted by Michael <sg...@gmx.net>.
Caldarale, Charles R wrote:
>> From: Michael [mailto:sgfan@gmx.net]
>> Subject: Re: HTTP Connector GZIP compression
>>
>> this is my server.xml: http://www.pastie.org/437454
>
> Other than having <Context> elements in there, the only other obviously wrong item is the compressionMinSize attribute; there isn't one for a <Connector>.
Correct, I removed that element.
>> CompressionMinSize is given bytes, isn't it?
>
> There's no such attribute for a <Connector>, so your question is moot. Read the doc:
> http://tomcat.apache.org/tomcat-5.5-doc/config/http.html#Standard%20Implementation
>
> You are testing through port 8080, aren't you? I don't see any problems with compression on 5.5.27 when testing on my laptop; I see a header of "Content-Encoding: gzip" on all appropriate responses.
>
> You need to supply the URLs you're using and the response headers as seen by the browser. (Live HTTP headers for Firefox is good for this.)
Yes, I am on port 8080. Local testing.
I have altered the Connctor to:
-------------------------------------
<Connector compression="80000"
compressableMimeType="text/html,text/javascript" URIEncoding="UTF-8"
acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true"
enableLookups="false" maxHttpHeaderSize="8192" maxSpareThreads="75"
maxThreads="150" minSpareThreads="25" port="8080" redirectPort="8443" />
-------------------------------------
I have two testfiles on my server:
1. lorem.jsp: 72 726 bytes
2. prototype.js: 134.057 bytes
According to the above setting only the JS file should be compressed.
Inspecting the requests with Fiddler and Firebug (caches cleared)
results in:
1. lorem.jsp:
# Result Protocol Host URL Body Caching Content-Type Process Comments
Custom
0 200 HTTP localhost:8080 /java-demo/lorem.jsp 19 665
text/html;charset=UTF-8 firefox:500
GET /java-demo/lorem.jsp HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8)
Gecko/2009032609 Firefox/3.0.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-DE,de;q=0.8,nl-NL;q=0.6,nl;q=0.4
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: JSESSIONID=E0EEB796A88FECFE98882E37EB499565
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Sun, 05 Apr 2009 16:57:07 GMT
a
�
2. prototype.js:
# Result Protocol Host URL Body Caching Content-Type Process Comments
Custom
1 200 HTTP localhost:8080 /java-demo/prototype.js 134 057
text/javascript firefox:500
GET /java-demo/prototype.js HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8)
Gecko/2009032609 Firefox/3.0.8
Accept: */*
Accept-Language: de-DE,de;q=0.8,nl-NL;q=0.6,nl;q=0.4
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:8080/java-demo/lorem.jsp
Cookie: JSESSIONID=E0EEB796A88FECFE98882E37EB499565
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
ETag: W/"134057-1238784461906"
Last-Modified: Fri, 03 Apr 2009 18:47:41 GMT
Content-Type: text/javascript
Content-Length: 134057
Date: Sun, 05 Apr 2009 16:57:07 GMT
[body omitted]
Regarding number 1: this is compressed although I set threshold to 80
000 bytes
Regarding number 2: the Javascript ist not compressed!
No I turn compression off:
# Result Protocol Host URL Body Caching Content-Type Process Comments
Custom
0 200 HTTP localhost:8080 /java-demo/lorem.jsp 19 665
text/html;charset=UTF-8 firefox:500
# Result Protocol Host URL Body Caching Content-Type Process Comments
Custom
1 200 HTTP localhost:8080 /java-demo/prototype.js 134 057
text/javascript firefox:500
lorem.jsp still compressed: WTF
This is really weird, I simply do *not* unterstand the compression logic.
Thanks,
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: HTTP Connector GZIP compression
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Michael [mailto:sgfan@gmx.net]
> Subject: Re: HTTP Connector GZIP compression
>
> this is my server.xml: http://www.pastie.org/437454
Other than having <Context> elements in there, the only other obviously wrong item is the compressionMinSize attribute; there isn't one for a <Connector>.
> CompressionMinSize is given bytes, isn't it?
There's no such attribute for a <Connector>, so your question is moot. Read the doc:
http://tomcat.apache.org/tomcat-5.5-doc/config/http.html#Standard%20Implementation
You are testing through port 8080, aren't you? I don't see any problems with compression on 5.5.27 when testing on my laptop; I see a header of "Content-Encoding: gzip" on all appropriate responses.
You need to supply the URLs you're using and the response headers as seen by the browser. (Live HTTP headers for Firefox is good for this.)
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
Re: HTTP Connector GZIP compression
Posted by Michael <sg...@gmx.net>.
Caldarale, Charles R wrote:
>> From: Michael [mailto:sgfan@gmx.net]
>> Subject: HTTP Connector GZIP compression
>>
>> I am on tomcat 5.5.27. Unfortunately compression worked arbitrary,
>> worked on html only and worked even when I turned it off.
>
> Please post your server.xml so we can see exactly what you configured. Note that the minimum default size for compression is 2048.
Hi Charles,
this is my server.xml: http://www.pastie.org/437454
CompressionMinSize is given bytes, isn't it?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: HTTP Connector GZIP compression
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Michael [mailto:sgfan@gmx.net]
> Subject: HTTP Connector GZIP compression
>
> I am on tomcat 5.5.27. Unfortunately compression worked arbitrary,
> worked on html only and worked even when I turned it off.
Please post your server.xml so we can see exactly what you configured. Note that the minimum default size for compression is 2048.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.