Leon Atherton Leon is a developer at IDRsolutions and product manager for BuildVu. He oversees the BuildVu product strategy and roadmap in addition to spending lots of time writing code.

How to Enable SVG Gzip Compression on Apache and NGINX

53 sec read

html5

Gzip compression is a widely supported method of reducing the size of the content sent from a web server in order to improve the load time. Effectively all browsers support this particular compression (IE6+, Firefox 2+, Chrome 1+, etc).

In our experience as the creators of a PDF to SVG converter, our research shows that SVG files, in particular, can be highly compressible. We find that some files reduce by as much as 80-90% when compressed!

The standard way to enable compression is on the web server. Tutorials that show how to enable this type of compression do not often include SVG files, so if you follow another guide you should make sure to apply compression to the image/svg+xml MIME-type.

Enabling Gzip compression on Apache

To enable apache Gzip compression add the following to the .htaccess file:

AddOutputFilterByType DEFLATE image/svg+xml

Read the official Apache documentation on configuring gzip compression

Enabling Gzip on NGINX

Add the following to the server configuration:

server {
gzip on;
gzip_types image/svg+xml;
gzip_proxied no-cache no-store private expired auth;
}

Read the official NGINX documentation on configuring gzip compression

Enabling Gzip on IIS

Read the official IIS documentation on configuring gzip compression

If you would like to do more with gzip compression, we recommend reading the official documentation (links above) to ensure you get the most accurate information.

You can also read this article to learn how to enable this type of compression on Tomcat, Jetty, GlassFish and Payara.



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
Leon Atherton Leon is a developer at IDRsolutions and product manager for BuildVu. He oversees the BuildVu product strategy and roadmap in addition to spending lots of time writing code.