All Collections
FAQs
Does ImageKit compress non-image files?
Does ImageKit compress non-image files?

Use of Brotli and gzip compression for non-image files delivered using ImageKit

Rahul Nanwani avatar
Written by Rahul Nanwani
Updated over a week ago

ImageKit supports delivery of non-image files using its CDN as mentioned in this article. Additionally, all files delivered via ImageKit CDN are compressed using Brotli and gzip compression, with preference given to Brotli compression wherever possible.

What is Brotli compression?

Brotli is a compression algorithm optimized for the web, in particular for small text documents.ย 

Is it better than gzip?

Till Brotli was introduced, gzip was the go-to standard for compressing content for delivery on the internet. However, compared to gzip compression, Brotli compression results in smaller file sizes. With ImageKit, your file size will go down by 8-14% without impacting the delivery time.

Browser-support for Brotli

Over 90% of browsers support Brotli compression. The latest browser support for Brotli compression can be found here - https://caniuse.com/#search=brotli.
โ€‹

How does ImageKit use Brotli or gzip compression?

If your browser supports Brotli compression and advertises support for it using the Accept-Encoding request header (explained below), then ImageKit will use Brotli compression. Otherwise, gzip compression is used by default. Once a resource is compressed using either compression algorithm, then it gets cached on the CDN and all your users get a cached copy of the resource.
โ€‹

How to check if Brotli compression is working for you?

The first thing to check is if your browser supports Brotli. If it does, then you would see that the Accept-Encoding request header would include "br", as shown in the screenshot below.
โ€‹

To check if the response that you get is Brotli encoded or not, you must look at the Content-Encoding response header. For Brotli compressed resources, the value for this response header is "br". Otherwise, it is "gzip".

Is Brotli compression used for images?

No, images are not subject to either Brotli or gzip compression. All image formats have their own compression algorithms suited for that particular format and ImageKit takes care of that.


For any issues or questions, you can contact ImageKit team at support@imagekit.io.

Did this answer your question?