Serving pre-compressed Brotli files

This is a follow-up to this comment:
https://answers.netlify.com/t/gzip-file-serving/3445/15

In relation to this site:
https://hugo-stork.netlify.app

As part of the build process, a 6.0 MB binary file (stork.index.json) is created in the root of site, consumed by a Wasm file for embedded site search. By giving the file a json extension[1], Netlify compresses with Brotli to produce a 2.1 MB file. This is excellent.

However, with aggressive Brotli compression ( -q 11) we can reduce the file size by another 28% to 1.5 MB.

We can improve performance and decrease cost by serving pre-compressed assets when present. For example:

public/
├── file.ext
├── file.ext.br
└── file.ext.gz

netlify-precompress-assets

Please let me know if there’s a way to accomplish this with what we have today.


  1. Yes, we’re lying about the file type to trigger compression. ↩︎

2 Likes