Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$> ls -al index.html
-rw-r--r-- 1 igrigorik 5000 21854 Dec 3 14:57 index.html
$> curl -vv --compressed http://w3c.github.io/preload/
* Trying 199.27.79.133...
* Connected to w3c.github.io (199.27.79.133) port 80 (#0)
> GET /preload/ HTTP/1.1
> Host: w3c.github.io
> User-Agent: curl/7.43.0
> Accept: */*
> Accept-Encoding: deflate, gzip
>
< HTTP/1.1 200 OK
< Content-Length: 7641
< ...
$> gzip -2 index.html
-rw-r--r-- 1 igrigorik 5000 7644 Dec 3 14:56 index.html.gz
$ > gzip -9 index.html
-rw-r--r-- 1 igrigorik 5000 6853 Dec 3 14:56 gh.gz
  • Original size: 21854 bytes on disk
  • Compressed size, as served by GH Pages: 7641 bytes
  • Closest match is gzip -2 -- interesting.

Default level is 6. Best compression is 9.

@frkay

This comment has been minimized.

Copy link

commented Dec 4, 2015

I made a video explaining how gzip compression works (in French) at about 21:20 you'll find a chart comparing the resulting size of the different gzip settings and even Kzip, Zopfli and bare Huffman (compressed file was book1 from the Calgary corpus).
http://www.dailymotion.com/video/x1umwga_le-fonctionnement-de-la-compression-gzip-frederic-kayser_tech

@frkay

This comment has been minimized.

Copy link

commented Dec 4, 2015

Same kind of results for your sample:
-rw-rw-r-- 1 fred fred 21854 déc. 4 02:17 index.html
-rw-rw-r-- 1 fred fred 12863 déc. 4 02:17 index.html-huffman.gz
-rw-rw-r-- 1 fred fred 7946 déc. 4 02:17 index.html-g1.gz
-rw-rw-r-- 1 fred fred 7641 déc. 4 02:17 index.html-g2.gz
-rw-rw-r-- 1 fred fred 7475 déc. 4 02:17 index.html-g3.gz
-rw-rw-r-- 1 fred fred 7033 déc. 4 02:17 index.html-g4.gz
-rw-rw-r-- 1 fred fred 6888 déc. 4 02:17 index.html-g5.gz
-rw-rw-r-- 1 fred fred 6856 déc. 4 02:17 index.html-g6.gz
-rw-rw-r-- 1 fred fred 6852 déc. 4 02:17 index.html-g7.gz
-rw-rw-r-- 1 fred fred 6850 déc. 4 02:17 index.html-g8.gz
-rw-rw-r-- 1 fred fred 6850 déc. 4 02:17 index.html-g9.gz
-rw-rw-r-- 1 fred fred 6616 déc. 4 02:17 index.html-kzip.gz

Huffman is produced using kzip (http://www.jonof.id.au/kenutils) set to Huffman only (s3), kzip2gz (http://encode.ru/threads/1630-kzip2gz-a-zip-%28single-file-amp-deflate-compression%29-to-gz-converter) is used to convert single file zip archive to plain gzip file.
kzip -s3 index.zip index.html ; kzip2gz index.zip index.html-huffman.gz

@jyrkialakuijala

This comment has been minimized.

Copy link

commented Dec 4, 2015

Zopfli on the same file:
-rw-rw-r-- 1 jyrki jyrki 6596 Dez 4 21:00 index.html.zopfli.gz

Brotli:
-rw-rw-r-- 1 jyrki jyrki 7184 Dez 4 21:07 index.html.q1.br
-rw-rw-r-- 1 jyrki jyrki 7149 Dez 4 21:07 index.html.q2.br
-rw-rw-r-- 1 jyrki jyrki 7109 Dez 4 21:07 index.html.q3.br
-rw-rw-r-- 1 jyrki jyrki 6832 Dez 4 21:07 index.html.q4.br
-rw-rw-r-- 1 jyrki jyrki 6381 Dez 4 21:07 index.html.q5.br
-rw-rw-r-- 1 jyrki jyrki 6362 Dez 4 21:07 index.html.q6.br
-rw-rw-r-- 1 jyrki jyrki 6363 Dez 4 21:07 index.html.q7.br
-rw-rw-r-- 1 jyrki jyrki 6364 Dez 4 21:07 index.html.q8.br
-rw-rw-r-- 1 jyrki jyrki 6359 Dez 4 21:07 index.html.q9.br
-rw-rw-r-- 1 jyrki jyrki 5556 Dez 4 21:07 index.html.q11.br

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.