tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leon Rosenberg <>
Subject Compression for Resources served through DefaultServlet
Date Mon, 26 Nov 2018 21:19:59 GMT
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"
               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:,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:
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?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message