4

This is configuration for gzip compression in Apache Tomcat 8

<Connector port="7070" maxHttpHeaderSize="8192"
       maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
       enableLookups="false" redirectPort="8443" acceptCount="100"
       connectionTimeout="20000" disableUploadTimeout="true" 
       compression="on" 
       compressionMinSize="256" 
       noCompressionUserAgents="gozilla, traviata" 
       compressableMimeType="text/html,text/xml,text/plain,text/css,application/javascript,font/otf,font/woff,
       font/woff2,image/gif,image/jpg,image/png"/>

png image is OK. It does not work for jpg image and woff2 font as below.

I already try as below, it does not work

image/jpg <or> image/jpeg <or> application/octet-stream

font/woff <or> font/woff2 <or> application/font-woff <or> application/font-woff2

Testing From Chrome

enter image description here

Zaw Than oo
  • 9,651
  • 13
  • 83
  • 131
  • 1
    Why would you want to compress already compressed formats like JPEG and PNG? You won't get any better results and will just waste power. – Sami Kuhmonen Jul 25 '17 at 09:46
  • I thought, If I can compress images and some resources (eg, jpg, font, png), the response time will be faster. – Zaw Than oo Jul 25 '17 at 09:47
  • 1
    PNG and JPEG are already compressed. You're making the response times worse for them. JS, HTML etc may benefit from compression. For images do optimization beforehand if needed. – Sami Kuhmonen Jul 25 '17 at 09:49
  • Thanks! well noted! I will re-configure my setting. But, one strange thing is it is work for `png` but for `jpg` as on image. – Zaw Than oo Jul 25 '17 at 09:53

1 Answers1

2

You're trying to compress already compressed files(gzip) like woff/woff2, jpg etc. From my point of view, it's just resource wasting. Not every type of file can be compressed (see:Fastly blog about gzip settings).

Here's the types Fastly recommends compressing by default:

Extensions: js css html json ico eot otf ttf

Content Types: text/html application/x-javascript text/css application/javascript text/javascript text/plain text/xml application/json application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/xml font/eot font/opentype font/otf image/svg+xml image/vnd.microsoft.icon

mjk
  • 2,443
  • 4
  • 33
  • 33
Aleksei Kurepin
  • 139
  • 2
  • 10