Speed up website by compression!

Speed up website by compression!

Why website speed is important?

  • Less time to transfer
  • Reduce page load
  • Saves bandwidth -> save money (Good for us and visitor)
  • First impressions
  • 47% of people expect web site to load in 2 seconds or less!
  • 40% will abandon if it takes longer than 3 seconds
  • User experience. It's feeling
  • Google don't like slow website. Your google ranking will affected

Compression format

  • Currently compression format is gzip, zopfli, brotli, bz2, xz
  • Most popular is gzip, but brotli is fast growing up
  • Compression is not free. It use CPU to operation
  • Text compression only, don't use with binary.
  • Compress static content, i.e. html, js, css, xml, svg, json, rss
  • Do not compress binary file such as images (jpg,png,gif) or multimedia (mp3,mp4). It already compressed. Not help.
  • Higher compression ratio (level) -> higher CPU usage
check out if static content encoded by brotli, gzip, bz2,...

Compression format

Gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and intended for use by GNU (the "g" is from "GNU"). Version 0.1 was first publicly released on 31 October 1992, and version 1.0 followed in February 1993. (source: wikipedia)

Bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm. It only compresses single files and is not a file archiver. It is developed by Julian Seward and maintained by Federico Mena. Seward made the first public release of bzip2, version 0.15, in July 1996 (source: wikipedia)

Brotli was first released in 2013 for off-line compression of web fonts. The version of Brotli released in September 2015 by the Google software engineers (source: wikipedia)


Base on brotli, gzip, xz and bz2 compression testing by Jeroen Ooms.

compression speed
decompression speed
compression ratio (effective)
Squash Compression Benchmark
Compare gzip brotli
Web browser support (caniuse.com) 100% 89.91%
Effective (size) fair best (better gzip, up to 30%)
compression speed best bad
decompression speed best fair

Web Browser supported?


The smaller files mean faster content delivery,  speed up web page load and reduce bandwidth cost!

I recommend to use brotli with static text content (html, css, js, svg, json, xml, rss, etc...) at level 4 is enough and use gzip for on-fly (dynamic) content.

brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;

More info