You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ran Berenfeld <ic...@ichess.co.il> on 2011/01/13 21:04:21 UTC

Tomcat 6.0 GZIP Compression not working for large js files

Hello
I'm using tomcat 6 for a deployed website (http://www.ichess.co.il)
and since the beginning, GZIP compression did not work for part of the
files.
the amazing thing is that the website have several javascript files, some
quite small
and some large, and the HTTP headers (for example when viewed using Firefox
"Live HTTP Headers" plugin) clearly shows that the compression works only
for the small
js file, and not for the large file.
I tried "playing" with the <Connector> at server.xml many times, and nothing
works.
Finally, I just added an external Gzip Tomcat Filter (and that solved the
problem...)

Here's the relevant part of my server.xml :

   <Connector port="80" protocol="HTTP/1.1"
        compression="1400"
compressableMimeType="text/html,text/css,text/javascript"
        URIEncoding="UTF-8" threadPriority="10"/>

If anyone encountered this issue, please share :)
Is there an open Tomcat ticket for it ? I couldn't find one

thanks
Ran


-- 
רן ברנפלד
מנהל
אתר השחמט הישראלי
*http://www.ichess.co.il*

Re: Tomcat 6.0 GZIP Compression not working for large js files

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ran,

On 1/13/2011 3:04 PM, Ran Berenfeld wrote:
> I'm using tomcat 6 for a deployed website (http://www.ichess.co.il)
> and since the beginning, GZIP compression did not work for part of the
> files.

:(

What specific version of Tomcat 6?

> the amazing thing is that the website have several javascript files, some
> quite small
> and some large, and the HTTP headers (for example when viewed using Firefox
> "Live HTTP Headers" plugin) clearly shows that the compression works only
> for the small
> js file, and not for the large file.

So it /does/ work for the small files? Good.

> I tried "playing" with the <Connector> at server.xml many times, and nothing
> works.
> Finally, I just added an external Gzip Tomcat Filter (and that solved the
> problem...)
> 
> Here's the relevant part of my server.xml :
> 
>    <Connector port="80" protocol="HTTP/1.1"
>         compression="1400"

Can you confirm that .js files smaller than 1400 bytes are not
compressed? Just trying to triple-check your configuration.

> compressableMimeType="text/html,text/css,text/javascript"

Can you confirm that all your files' MIME types are text/javascript?

>         URIEncoding="UTF-8"
>         threadPriority="10"/>

Is there a reason you changed the priority of the threads? Presumably,
your request processing threads represent nearly all of the threads
running in the JVM. If they're all at MAX_PRIORITY, you're not really
gaining anything.

What else can you tell us about these "large" Javascript files? Are they
static files loaded directly from the disk, or are they
dynamically-generated? Are you sure that thee content-type is being set
correctly for these files?

Are you using Tomcat standalone or do you have something in front, such
as Apache httpd? Just making sure that Tomcat is doing the compression
for you.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0vbssACgkQ9CaO5/Lv0PBwkwCdEjaYdMO+kOrHO+rHiQFZSoL1
V3AAmQH3uvGKmMIRwJoubx2mUshv34dE
=5o35
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 6.0 GZIP Compression not working for large js files

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/1/14 Ran Berenfeld <ic...@ichess.co.il>:
> it's a pity it's not documented somewhere, that the "default" tomcat
> settings actually fails to compress
> anything above 48KB size. (well actually the defaults is not to compress at
> all....)

I updated the TC7 and TC6 documentation by adding a comment to the
"compression" attribute of an HTTP connector. Will be in 6.0.31,
7.0.7.

http://svn.apache.org/viewvc?rev=1059897&view=rev
http://svn.apache.org/viewvc?rev=1059898&view=rev

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 6.0 GZIP Compression not working for large js files

Posted by Ran Berenfeld <ic...@ichess.co.il>.
Thank you very much !
indeed, it was that "sendFile" feature.
I disabled it by setting sendFileSize to -1 in the default servlet (and I
guess disabling it useSendfile="false"
would be the same)
after disabling this "sendfile" feature, all js files, small and large, are
compressed correctly.

it's a pity it's not documented somewhere, that the "default" tomcat
settings actually fails to compress
anything above 48KB size. (well actually the defaults is not to compress at
all....)

problem is now solved, and I removed the custom gzip filter.

Ran


On Fri, Jan 14, 2011 at 9:30 AM, Konstantin Kolinko
<kn...@gmail.com>wrote:

> 2011/1/13 Ran Berenfeld <ic...@ichess.co.il>:
> > Hello
> > I'm using tomcat 6 for a deployed website (http://www.ichess.co.il)
> > and since the beginning, GZIP compression did not work for part of the
> > files.
> > the amazing thing is that the website have several javascript files, some
> > quite small
> > and some large, and the HTTP headers (for example when viewed using
> Firefox
> > "Live HTTP Headers" plugin) clearly shows that the compression works only
> > for the small
> > js file, and not for the large file.
>
> Maybe those are sent by "sendfile" and thus avoid being compressed.
> There is certain size threshold (48 Kb, set by sendfileSize parameter
> on DefaultServlet)
>
> Try to set useSendfile="false" on your Connector.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
רן ברנפלד
מנהל
אתר השחמט הישראלי
*http://www.ichess.co.il*

Re: Tomcat 6.0 GZIP Compression not working for large js files

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/1/13 Ran Berenfeld <ic...@ichess.co.il>:
> Hello
> I'm using tomcat 6 for a deployed website (http://www.ichess.co.il)
> and since the beginning, GZIP compression did not work for part of the
> files.
> the amazing thing is that the website have several javascript files, some
> quite small
> and some large, and the HTTP headers (for example when viewed using Firefox
> "Live HTTP Headers" plugin) clearly shows that the compression works only
> for the small
> js file, and not for the large file.

Maybe those are sent by "sendfile" and thus avoid being compressed.
There is certain size threshold (48 Kb, set by sendfileSize parameter
on DefaultServlet)

Try to set useSendfile="false" on your Connector.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org