Enabling GZIP Compression
GZIP compression is a widely supported method of reducing the file size of the content sent from the webserver to a web browser, improving the load time. It is supported in effectively all browsers (IE6+, Firefox 2+, Chrome 1+, etc).
It is highly recommended to enable GZIP compression for files produced by BuildVu. In particular, we have found that generated SVG files are highly compressible (in our testing we found example files reduced by as much as 80-90% when compressed).
When using BuildVu we recommend enabling compression for .html
, .css
, .js
, .svg
, and .json
files, as these cover all of the compressible formats that BuildVu will produce.
Note: Modern web servers also support brotli compression, which generally provides a higher compression ratio than gzip. We recommend using brotli instead of gzip when possible.
Option 1: Enabling GZIP on the webserver
The standard way to enable compression is on the webserver. Tutorials that show how to enable gzip compression do not tend to include the SVG mime type, so if you are following another guide you will need to make sure that compression is applied to the image/svg+xml
mime type.
Enabling GZIP on Apache
Add the following to the .htaccess
file:
AddOutputFilterByType DEFLATE image/svg+xml text/html text/css text/plain text/javascript application/javascript application/json
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 text/html text/css text/plain text/javascript application/javascript application/json;
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
Option 2: Enabling GZIP at conversion time (SVG only)
BuildVu can be configured to generate SVGZ files instead of SVG (SVGZ files are simply SVG files which have been GZIP compressed). Pre-generating GZIP compressed SVG can be useful as the webserver will not need to compress the file when it is served (which may improve performance).
Instructions for enabling this setting in BuildVu are available at compressSVG.
Important: You will need to make sure that the SVGZ files are served with the
Content-Encoding: gzip
header in order for web browsers to understand them.
If you are serving the generated content from Apache, this can be achieved by adding the following to the .htaccess
file:
AddType image/svg+xml svg svgz
AddEncoding gzip svgz