# Gzip

## Contents

gzip is a patent-free compression program for files which is defined in web standard RFC1952 [1]. The software was originally written for the GNU platform and can now be used on almost all platforms. Files compressed with gzip can be interpreted by all modern browsers. The term “gzip” is composed of “g” for the GNU operating system and “zip” for zipper.

## Background

gzip was developed by Jean-Loup Gailly. The aim of the development was to find a substitute for the compression method “compress,” which was written for Unix. In addition to gzip, Gailly also wrote the code for the data compression method “zip.” He is also co-author of the zlib library which makes it possible to compress PNG files. Today, gzip is a popular compression method that has been established especially for websites. Search engines such as Google recommend gzip as a method of data compression to increase the load speed. In practice, compression rates of up to 90 percent can be achieved with gzip, especially if mostly text files are being compressed.

## How it works

gzip is based on the LZ77 algorithm and its successor, the LZH method, combined also called “deflate algorithm.” This method is already used in the popular compression program Winzip and has been utilized for the Apache server since the beginning. However, gzip was not always being released by each server. If gzip is enabled, it analyzes the existing file for duplicate data. These components are replaced by a reference to an existing component. Each block of a gzip file consists of 32,000 bytes. If a byte sequence is not repeated, the file remains uncompressed and stored in .gz format. Where repeated characters are found, the block size can be reduced, in other words compressed. Only individual files can be compressed with the gzip process. If you want to pack archives, they have to be combined into “tarballs.” This file collection then gets the suffix .tgz. If a website gets retrieved where the files have been compressed with gzip, the browser decompresses them and reassembles them as part of rendering.

## Implementation

gzip can be implemented using plugins, PHP or the .htaccess file.

• .htaccess: You can define rules for servers with the .htaccess file. In this case, the request for data compression will be stored there.

One possible example:

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
</ifModule>
• PHP: A code gets inserted in each PHP file, which is supposed to contribute to compression of the website.
<?php
ob_start(“ob_gzhandler”);
?>
• Plugins: Utilities for gzip compression exist for many different CMS such as Joomla or Wordpress. With plugins, users do not need to make any changes to the PHP file or .htaccess themselves.

## Benefits for SEO

Fast load times increase the usability of a website. The less time a website requires to load, the lower is the chance that users will bounce. The possibility of a conversion at online stores increases with faster load times.[2]. The increased duration of the visit represents positive user signals to search engines that will be incorporated into the overall assessment of the website. Moreover, the performance of a website is a ranking factor. If you use gzip, you can optimize performance and achieve better a ranking that way.

## References

1. GZIP file format specification version 4.3 ieft.org Accessed on 02/18/2016
2. How to improve your conversion rates with a faster website moz.com Accessed on 02/19/2016