0

Recently, I enable the Gzip compression module for resources access on a server manually. Most files have gotten smaller as expected, but there is a file format that is not smaller but larger - .woff font. When I enable the Gzip module, a .woff file size with 3.2 KB. Conversely, it is only 2.1KB normally. Why do this happen?

Rick Dou
  • 154
  • 9
  • Welcome to Stack Overflow! If you search for this topic online or even on SO, you can find many resources discussing it. Weren't they useful for you? – viam0Zah Jan 21 '22 at 09:07
  • 1
    Hint: The WOFF format stores already compressed data. https://developer.mozilla.org/en-US/docs/Web/Guide/WOFF – viam0Zah Jan 21 '22 at 09:09
  • Here's another answer too: https://askubuntu.com/questions/455783/compressing-videos-create-even-larger-file – viam0Zah Jan 21 '22 at 09:12
  • .woff files are already compressed. Compressed (as well as encrypted) files are slightly _expanded_ by a compressor. However your example of 2.1K going to 3.2K is not at all what's expected. There should only be a very slight increase. 2.10K of random data results in 2.12K after gzip compression. Can you provide the .woff file for which this happens, and the resulting .gz file? – Mark Adler Jan 21 '22 at 19:45

1 Answers1

3

You cannot compress every kind of data.

Compression usually adds some overhead. But it also removes redundancy. So if you have a file that doesn't have enough redundancy, the achieved compression cannot make up for the overhead introduced by the compression format.

WOFF is a compressed file type. So redundancy has already been removed.

ziggystar
  • 28,410
  • 9
  • 72
  • 124