Discussion:
Compression for Resources served through DefaultServlet
Leon Rosenberg
2018-11-26 21:19:59 UTC
Permalink
Good time of the day,

I am debugging bad page insights reported by google for a mobile versus
desktop version of our site and I'm seeing that the static resources,
served by the DefaultServlet (aka files) aren't compressed, versus to
dynamic resources served by a servlet.
Tomcat version in question 8.5.15 and 8.5.31 (tested on both)

Connector setting:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000" URIEncoding="UTF-8"
compression="on"
redirectPort="8443" maxThreads="1000"/>
There is a loadbalancer in front of the connector, but its transparent,
doesn't change anything.

Now when I request a resource like this:
https://www.mysite.com/rd/V-2.0.0-SNAPSHOT_2018-11-22T13:39:22,000/static-ext/bootstrap.css
(where rd is mapping to a servlet) the result is shown in inspect tab of
chrome as 18.K (obviously compressed) and the response headers indicate
that the file is gziped:

HTTP/1.1 200 Last-Modified: Tue, 31 Jul 02018 11:42:50 GMT Expires: Tue, 26
Nov 02019 21:15:04 GMT Content-Type: text/css Transfer-Encoding: chunked
Content-Encoding: gzip Vary: Accept-Encoding Date: Mon, 26 Nov 2018
21:15:04 GMT

If I make a request to a static file the file is not gziped:
https://www.mysite.com/static-ext/css/bootstrap.css
HTTP/1.1 200 Accept-Ranges: bytes ETag: W/"131194-1539850288000"
Last-Modified: Thu, 18 Oct 2018 08:11:28 GMT Content-Type: text/css
Content-Length: 131194 Date: Mon, 26 Nov 2018 20:53:37 GMT


Are there any specific settings to the default servlet to enable it to
support compression? Both files are css, hence they should be covered by
default compression types. Are there any other settings to try?

regards
Leon
Mark Thomas
2018-11-26 21:27:24 UTC
Permalink
Post by Leon Rosenberg
Good time of the day,
I am debugging bad page insights reported by google for a mobile versus
desktop version of our site and I'm seeing that the static resources,
served by the DefaultServlet (aka files) aren't compressed, versus to
dynamic resources served by a servlet.
Tomcat version in question 8.5.15 and 8.5.31 (tested on both)
http://tomcat.apache.org/tomcat-8.5-doc/config/http.html

Search for sendfile.

?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Leon Rosenberg
2018-11-26 23:53:02 UTC
Permalink
Post by Mark Thomas
Post by Leon Rosenberg
Good time of the day,
I am debugging bad page insights reported by google for a mobile versus
desktop version of our site and I'm seeing that the static resources,
served by the DefaultServlet (aka files) aren't compressed, versus to
dynamic resources served by a servlet.
Tomcat version in question 8.5.15 and 8.5.31 (tested on both)
http://tomcat.apache.org/tomcat-8.5-doc/config/http.html
Search for sendfile.
?
I thought sendfile is NIO only, this was probably the mistake.

Thank you.
Leon
Post by Mark Thomas
Mark
---------------------------------------------------------------------
Christopher Schultz
2018-11-27 00:53:48 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Leon,
Post by Leon Rosenberg
Post by Mark Thomas
Post by Leon Rosenberg
Good time of the day,
I am debugging bad page insights reported by google for a
mobile versus desktop version of our site and I'm seeing that
the static resources, served by the DefaultServlet (aka files)
aren't compressed, versus to dynamic resources served by a
servlet. Tomcat version in question 8.5.15 and 8.5.31 (tested
on both)
http://tomcat.apache.org/tomcat-8.5-doc/config/http.html
Search for sendfile.
?
I thought sendfile is NIO only, this was probably the mistake.
It's for NIO/NIO2 and APR, and on by default. Those are the only
connectors available these days, so by default sendFile=true and
therefore compression=false.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlv8lZsACgkQHPApP6U8
pFg7GhAAnYAlwdMTkpe1i995Q1mFKfOV5GTU8IpqFXFadnaiNov/mpWX64IVSGQB
3B2m0CwHgQE1Nv0lh/3AHleqC54S5i8Hiuhw3YiYBQ6xfKVbctrG2m+97WtgXSzG
lwV2pUw1nsJlJ/Wlnc+/Pf1DUN6p5r8IMSIP4NnuhM0KSYwJi60bN2w10ZJsMpDR
6DFkLMT+g3LQ7lvsRsol99AQkpbkeEpUypRr1y5/duvkqz/8A/8WX4kZ7+Ix5oah
y+hLmd31nqjE03wAnacLfiMQ4ziUzh0MNKfjJUnccOvK5eXLSpE6uvAtA6nsMuAK
3HxsGsDTc6wdeF6oEU3MY16AdnG6mGOhfASCv5tMqkDYrzKLnznN7dmYCpzikgjR
S3SzYGoXm+YE5n0ciA/aKat+701YJZX9N9LJak60A9+eJ9Xr0gG81t/4H6FW8uo2
0M5ukNhBy08M5yqFbz3rQmDEZdOsCOCO9Mb+2ABusnjupnadBCfonUSD+JVNezXm
7im0PiiNuXGigrmURS85xAtE3VJIt9mTCylbLxMDMJw3LdZUrMpd0AK/VuBPK5/0
zjn1JvqB6qosdCqnKvERk85EKY4c4mfqVVVDl0Ok0pJcH5x3rgnmyaysjDaUy0sX
ap3plQplGRpJI6J+b9QLrviYEq/4uFYabQIoEJ7p1Lm+Jq8JjhI=
=eiE1
-----END PGP SIGNATURE-----

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

Loading...