Enable HTTP Compression (gzip)
Last modified by Eleni Cojocariu on 2026/05/20 16:51
Steps
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:
- Open the server.xml file in the Tomcat configuration directory. (Usually located in /tomcat_version/conf).
- Locate the <Connector> element used for HTTP traffic.
- 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" - Save the server.xml file.
- Restart the Apache Tomcat server.
- 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.