whitenoise
whitenoise copied to clipboard
Consider using zopfli to generate .gz files
Description
The Zopfli compressor generates gzip-compatible compressed files smaller than zlib, and often pretty close to Brotli. For example I use the Python bindings to compress some web assets here:
ORIGINAL ZOPFLI (.gz) BROTLI (.br) FILE
--------- --------------- -------------- ------------------------------------------
6,138 1,686 27% 1,398 23% normalize-8.0.1.css
318,964 161,987 51% 141,848 44% inconsolata-33dd95333e9e.ttf
515 199 39% 178 35% fonts-8e4fe55c0023.css
22,141 4,573 21% 4,037 18% main-b75bac5769ba.css
9,310 2,512 27% 2,355 25% main-b75bac5769ba.css.map
5,805 1,149 20% 1,043 18% icon-bd3da638f8c2.svg
2,544 1,056 42% 976 38% lettertype-dc874be920ee.svg
8,957 1,940 22% 1,879 21% logotype-a492afd710d0.svg
24,838 4,849 20% 4,555 18% icon-4a76ea6aede6.ico
The main downside is that Zopfli is much slower than zlib, like Brotli.
It is slower... wikipedia:
Under default settings, the output of Zopfli is typically 3–8% smaller than zlib's maximum compression, but takes around 80 times longer.
Whitenoise already adds a considerable overhead to deploys by doing so much work compressing up front, in serial (often including third party files that aren't served). I wouldn't want to slow it down further for savings when Brotli is already supported, and widely supported by browsers.
It could perhaps be an option, but I'd like to see more evidence that it's really desirable.
Is zopfli really the official library? It only has 12 stars, doesn't seem to be so popular.
Whitenoise already adds a considerable overhead to deploys by doing so much work compressing up front, in serial (often including third party files that aren't served). I wouldn't want to slow it down further for savings when Brotli is already supported, and widely supported by browsers.
It could perhaps be an option, but I'd like to see more evidence that it's really desirable.
Agreed, there's a tradeoff here. I doubt it's worthwhile for large files. I just wanted to make sure you were aware it exists. Unfortunately I don't have any data on .gz vs .br hit rates to share.
Is
zopflireally the official library? It only has 12 stars, doesn't seem to be so popular.
The only other one I've found is pyzopfli which appears unmaintained. IIRC I selected zopfli because it:
- Provides wheels
- Appeared to be maintained by Googlers (like Zopfli itself), though this no longer seems to be the case
Okay. I think the best course of action right now is to leave this open, and if others show support for the feature then we can look into it.