How To Compress Your Website

A website is consist of web pages, scripts, images and multimedia contents such as videos and audios. It is accessible, interlinked, and share a single domain name. Since most of the website components are text-based, it is possible to compress a website to a smaller size.

In this article, I will show you what is website compression and how to compress your website. You might also interested in how to optimize images for your website or how to minify your scripts and stylesheets. This article is part of best useful tips for your WordPress.

What Is Website Compression

If you ever use file compression tool or software such as WinRAR, 7-Zip or similar, then you will be familiar with the process. Compression is a process of reduction in the number of bits required to represent data. With compression, you can speed up your data transfer or save your storage capacity.

In a similar manner, website compression is the same process for your web page files such as HTML, PHP, CSS or Javascript. It will reduce the file size of your web pages up to 70% and speed up file download. Moreover, it will also decrease the cost of bandwidth usage for both your server and visitors. Please take a look at both images below.

How To Compress Your Website
Example of communication between a browser and web server (without compression).
How To Compress Your Website
Example of communication between a browser and web server (with compression).

Type Of Compression

There are few types of web compression exists. A different kind of server has a different type of HTTP compression. Below are some of the HTTP compression:

  1. Compress - A Unix shell compression program and created based on the LZW compression algorithm. It compression performs faster and use less memory. This method is deprecated in most applications and replaced by Gzip or Deflate.
  2. Deflate - A compression based on the deflate algorithm. It uses a combination of the LZ77 algorithm and Huffman coding.
  3. Gzip - Or GNU zip format is a compression that uses the deflate algorithm. However, data format and the checksum algorithm is different compared to the "deflate" content-encoding. Currently, this compression method is the most broadly supported.
  4. Bzip2 - A free and open source data compression method.It uses the Burrows-Wheeler algorithm and supported by Lighttpd. It is developed and maintained by Julian Seward and only compresses single files and is not a file archiver.
  5. Exi - Stand for Efficient XML Interchange. It is a binary XML format for exchange of data on a computer network by World Wide Web Consortium (W3C).

How To Compress Your Website

Before you start, I would like to recommend you to check your website compression status beforehand. It is because some of the web hosting companies may already set up the compression method for you. Hence, there is no need to compress your website again.

For this matter, you can use free online compression checker. There are many free compression checkers you can use such as this, this, this and many more. You may want to use few different tools to verify that your site compression is truly enabled.

Apache Server (Mod Deflate)

Mod deflate is the easiest compression method to set up. It is an Apache Web server module which is based on the Deflate lossless data compression algorithm.

To use mod deflate, open up your cPanel and navigate to your File Manager. Next, open your File Manager and select your preferred domain. Then, open your .htaccess file, enter the following snippet and save it. Please keep in mind that .htaccess file is a hidden file. So you may need to check the "show hidden files (dotfiles)" box while opening your File Manager.

Alternatively, you can use the following snippet in your .htaccess file if you prefer to compress certain files type by extension.

Apache Server (Mod Gzip)

Mod Gzip is another module for Apache Web server. It is compression alternative method. Although both Mod Gzip and Mod Deflate use similar compression type, however, it has a different configuration.

While Mod Deflate is more modern, but it is only usable with Apache v2. Furthermore, Mod Gzip is also well documented and widely support. To use Mod Gzip, open your .htaccess file, enter the following snippet and save it.

NGINX Server

If you are using Nginx server, you can also compress your website. However, some of the web hosting providers may restrict your access to the configuration file. If that is not the case, you can add the following snippet to your nginx.conf which usually located at /etc/nginx/nginx.conf.

IIS Server

For IIS Web server user, on the other hand, is able to use few kinds of compression. You can choose whether to use static compression, dynamic compression or both compression at the same time. Please take a look at the Microsoft guide for further instruction.


Definitely, compressing your website is one of the best ways to speed up your website load speed. It will also save bandwidth usage for both your server and your visitors who are connected through mobile. Which in any case, will benefit both parties.

If you have something you would like to share on this topic, please don't hesitate to let us know in the comment section.

  • If you think your friends would find this useful, please share it with them. It will allow us help more people.
  • To get more of our latest update, please subcribe to our newsletter.
  • You can also print this article for reference.
This article has been printed from

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.