GZIP Compression is a widely supported method of reducing the file size of the content hosted by your Java Application Server. This reduces bandwidth usage and improves load times. We recommend enabling GZIP compression for .html, .css, .js, .svg, and .json files.
Follow the instructions below to enable GZIP compression of static assets hosted by Tomcat, Jetty, GlassFish or Payara.
Tomcat
- Open
conf/server.xml
- Find
<service name="Catalina">
- Find the
<Connector />
tag inside it - Add the following attributes to the Connector tag:
compression="on"
compressionMinSize="2048"
noCompressionUserAgents=""
compressableMimeType="text/html,text/css,text/plain,text/javascript,application/javascript,application/json,image/svg+xml"
- Restart the server and you’re done
Jetty
- Open
etc/jetty.xml
- Find the
<Configure id="Server" class="org.eclipse.jetty.server.Server">
tag - Add in the following lines inside the Configure tag
- Restart the server and you’re done
GlassFish
- Open the GlassFish admin console (
localhost:4848
for example) - Go to the HTTP settings via: Configurations → server-config → Network Config → Network Listeners → http-listener-1/http-listener-2 (change the settings in both of these) → HTTP (tab at the top of the page)
- Edit the ‘Compression’ setting to be ‘on’
- Change the ‘Compressible Mime Types’ to use
text/html,text/css,text/plain,text/javascript,application/javascript,application/json,image/svg+xml
- Click save and you’re done
Payara
- Open the Payara admin console (
localhost:4848
for example) - Go to the HTTP settings via: Configurations → server-config → Network Config → Network Listeners → http-listener-1/http-listener-2 (change the settings in both of these) → HTTP (tab at the top of the page)
- Edit the ‘Compression’ setting to be ‘on’
- Change the ‘Compressible Mime Types’ to use
text/html,text/css,text/plain,text/javascript,application/javascript,application/json,image/svg+xml
- Click save and you’re done
Our software libraries allow you to
Convert PDF files to HTML |
Use PDF Forms in a web browser |
Convert PDF Documents to an image |
Work with PDF Documents in Java |
Read and write HEIC and other Image formats in Java |