What Is Brotli Compression? | How Does It Work?

What Is Brotli Compression? | How Does It Work?

Data compression is essential in today’s data-driven environment since it makes data storage cheaper and data transfer quicker. In 2015, Google introduced Brotli, an open-source, lossless data compression algorithm. The Brotli algorithm offers higher compression ratios, faster speeds, and more efficient memory usage than other popular compression algorithms. Let’s take a look at how Brotli works and how you can use it for free with Gcore.

What Is Brotli Compression?

Brotli is a high-efficiency, lossless compression algorithm developed by Google that significantly reduces file sizes, enhancing web performance and decreasing bandwidth usage. Brotli achieves higher compression ratios compared to traditional algorithms such as gzip. This means faster loading times for websites and a smoother user experience, particularly for users on mobile devices or with slower internet connections.

How Does Brotli Work?

Brotli operates in three stages: preprocessing, compression, and decompression.

Stage 1: Preprocessing

Brotli begins by preprocessing the input data to improve its compressibility. This involves detecting and handling patterns and repetitions in the data. Preprocessing can include tasks like dictionary matching, where frequently occurring sequences are replaced with shorter codes using a static dictionary. This step helps to reduce redundancy in the data.

Stage 2: Compression

The core of Brotli’s functionality lies in its ability to compress data efficiently. This stage involves several key techniques:

  • Meta-blocks: Brotli splits the input data into meta-blocks, which can be independently compressed. This segmentation helps optimize compression by allowing different blocks to use different compression parameters.
  • Entropy encoding: Brotli encodes the data using a combination of Huffman coding and context modeling. Huffman coding replaces frequently occurring symbols with shorter codes, while context modeling predicts the probability of symbols based on their context, further enhancing compression. Brotli’s algorithm uses a predefined dictionary consisting of almost 120,000 commonly used words, phrases, and patterns to reduce the size of the files being processed—also known as a high compression ratio. To achieve this, Brotli uses a combination of a modern version of the LZ77 algorithm, Huffman coding, and second-order context modeling.
  • Backward references: Brotli identifies repeated patterns in the data and replaces them with backward references, which point to the previous occurrences of those patterns. This method reduces the amount of data that needs to be stored.

Stage 3: Decompression

Decompression is the reverse of compression. It involves reading the encoded data, interpreting the Huffman codes, and reconstructing the original data using the backward references and dictionary matches. Since Brotli is a lossless compression algorithm, the decompressed data is an exact replica of the original input data.

Advantages of Brotli

Brotli is at least 20% more efficient than Zopfli and gzip at compressing HTML, CSS, and JavaScript files. Brotli comes out on top when comparing compression ratio, compression speed, and decompression speed across providers. This translates to reduced bandwidth consumption and improved content loading times compared to its alternatives.

Table comparing Brotli to other algorithms, showing that Brotli comes out on top for compression ratio, compression speed, and decompression speed
Compression algorithm comparison showing Brotli’s superiority, indicated by the bold numbers

Brotli offers benefits beyond faster webpage loading times. Its high compression ratio reduces transmitted traffic, which conserves devices’ battery power.

In addition, as of April 2024, Brotli works for over 97% of internet users because it’s supported by almost all Chromium-based browsers, including Chrome, Opera, Firefox, and Yandex.

Brotli accept-encoding/content-encoding stats as of April 2024, showing 97% global potential use
Brotli is supported by over 97% of global users

Since Brotli compression can be applied to many common types of web data and is broadly supported, it has wide-reaching use case potential. Its benefits can be further enhanced with a CDN.

Delivering Brotli-Compressed Content with a CDN

Brotli compression helps a CDN reduce the amount of traffic delivered to end users. A CDN retrieves uncompressed files from the origin server and applies compression before caching them on the edges. Then, this compressed and lightweight content becomes available for users and can be served from a cache with very low latency.

Gcore CDN and Origin Shielding

Gcore CDN offers all the usual benefits of a Brotli-compatible CDN and enhances file compression with an Origin Shielding feature. Origin shielding means that an uncompressed file version is taken from the origin, compressed on the CDN side, and distributed to users whose browsers support Brotli compression.

The key benefits of origin shielding are security and stability. They are enhanced by reducing the load on the origin server, ensuring consistent performance, and optimizing caching efficiency.

How to Activate Brotli with Gcore

To enable Brotli via the Gcore Customer Portal, open “Resource settings,” and click Brotli Compression under “Content.” Toggle on “Brotli Compression” and click Save changes. By default, Brotli compression is disabled on Gcore CDN.

A file can be compressed to a minimum size of 128 bytes. The Brotli compression feature can only be used when origin shielding is enabled.

Upon activation, compression is performed using origin shielding. If no precache server is used for the resource, compression is not performed even if the option is enabled. For assistance enabling origin shielding, contact technical support.

Accelerate Your Performance for Free with Gcore CDN

Whatever your industry—media and entertainment, gaming, e-commerce, financial services, technology, or telecommunications—your customers deserve fast, secure, and reliable performance powered by a robust edge network. Gcore offers world-class CDN and edge network solutions to meet your static and dynamic content delivery needs at any scale. Sign up for Gcore CDN today to maximize Brotli compression and deliver your content quickly and reliably.

Explore Gcore CDN

What Is Brotli Compression? | How Does It Work?

Subscribe
to our newsletter

Get the latest industry trends, exclusive insights, and Gcore
updates delivered straight to your inbox.