Gzip file serving

In my quest for a faster site I´m looking to serve gzipped files.
So I guess I have two options.
1 gzip my files in the build process
2 have the server do the gzipping for me
if I were to go for number 2 I{m I correct in thinking that I would have to add this to my headers configuration in the netlify.toml file?

Does any one have any tips or previous experience with this? Any tips greatly appreciated

Netlify already gzips files transparently.

However, it would be excellent if Netlify supported serving of precompressed files if present. The reason is that you can often gain a 3-8% savings by using the zopfli algorithm for gzipping, which is fairly CPU intensive and should be done in the build step rather than on a per-request basis.

The same goes for supporting brotli. Dropping a /static/my.js.gz or a /static/my.js.br could transparently serve the right format if requested.

1 Like

we have a thread, here on supporting brotli:

If we decide to implement, we’ll let you know when we can - we know this is an ask for several people.

As far as serving precompressed files - this is the first time someone has requested this - can you outline your use case a bit more and potentially your experience with this?

thanks!

Zopfli can reduce the size of files beyond what a simple gzip pass can, but it takes much longer to compress. I think it’s unreasonable to expect Netlify to compress responses with zopfli transparently, but we could achieve the same gains by compressing files in the build process. It would then be up to Netlify to look for a <filename.gz> and serve that if present, instead of gzipping “on the fly”.

1 Like