There are many techniques in SEO that are quite easy to implement. Some of them also have other advantages in addition to improving your SEO “score” with search engines. Enabling compression on your web pages is one of them. This allows you to save bandwidth, download time as well as improve the page load times.
Page speed is an important factor in SEO. Faster loading web pages keep the users happy as well as tend to do better in search engine rankings. What compression helps you with is the page speed of your web pages.
There are primarily two different types of compressions that are used: gzip and deflate. Gzip compression is the most used and usually the default implementation used by most web sites, but you can also use deflate with good effect.
The total page size or the payload size is the sum of all these files. So, Keeping the total size to a minimum will reduce the total download time and increase the page load times. We know that compression is a good way to make large files smaller, that helps to transfer of files over the wire faster as well.
In order to compress the file and display it correctly to the user, there are several little things that need to happen. Both the web server and web client/web browser need to understand that the file is to be compressed. When the browser makes a request for the web page, it will also send the list of encodings or encoded content types that it can “understand” and properly handle from the server. This is conveyed using the header field in the request named Accept-Encoding.
Depending on the value of the Accept-Encoding header in the request received from the client, the server then decides on the format in which the content should be sent to the client. If the server decides to serve the content in the compressed format, then it will send along the type and format of the content again using a HTTP header field in the response: Content-Encoding.
You can configure your web server to serve compressed content as and when the browser supports it. Most modern web servers support compression either by using built-in routines or by using third party modules. Let us see the differences between the two widely used compression techniques to find which one should ideally be used.
Deflate vs Gzip
deflate is a very simple compression technique and it is pretty fast as well. This makes it a good choice when speed of compression and ease of implementation is a factor. Despite some of the conveniences of deflate, gzip is much more widely used than deflate.
Gzip usually have a better compression ratio than deflate making it ideal when size is a major factor. Gzip also allows you to pre-compress the files, thus saving a little bit of time and processing load on the server. These compressed files can then be cached for even faster downloads.
In Apache Web Server, you can enable compression in the .htaccess file. Apache can use either of the compression methods: deflate or gzip. You specify the compression method using the corresponding apache module: mod_gzip or mod_deflate. You can enable compression based on the file type or by the file extension.
Insert the following code into your .htaccess file located in the topmost folder of the web site.
The apache code for enabling deflate is pretty similar to the above one for Gzip. Below is an example of specifying the compression on a per mime type basis.
No matter how you enable compression, you need to verify that the compression feature is working. You can do using any of the web page analysis software or online websites such as Page Speed Services, Pingdom or Check Gzip compression. etc.
In addition to enabling the compression feature, there are several things that you can do to make sure that the web compression works optimally to give you the best performance.