Enable HTTP Compression (gzip)

Last modified by Eleni Cojocariu on 2026/05/20 16:51

Content

Steps

Warning

WIP

To enable HTTP compression, meaning to reduce the size of HTTP responses sent from the server to the browser in order to improve load times and reduce network usage, configure gzip compression in Apache Tomcat as it follows:

  1. Open the server.xml file in the Tomcat configuration directory. (Usually located in /tomcat_version/conf).
  2. Locate the <Connector> element used for HTTP traffic.
  3. Add or update the following attributes inside the Connector:
    <Connector port="8080"
    ...
    compression="on"
    compressionMinSize="2048"
    compressibleMimeType="text/html,text/xml,text/css,text/javascript,application/json"
  4. Save the server.xml file.
  5. Restart the Apache Tomcat server.
  6. Verify that the application is accessible via the HTTP connector port.

FAQ

How do I know if gzip compression is enabled?

Check the browser DevTools > Network tab, and confirm the response header contains Content-Encoding: gzip.

Get Connected