GZIP compression is the process of taking your data and reducing its size by removing unnecessary characters like spaces and punctuation marks. When you use GZIP, the server can compress your data before it sends it to the client. The client then has less work to do when receiving the data, so it can receive it faster.
When you send data over a network, there are two main parts: sending and receiving. Sending involves taking your data and sending it from your computer to the server. Receiving involves taking that data and making sure it gets into your computer intact. There are lots of different things that can go wrong along these two lines – from losing power to having bad internet connections. When you compress your data, you reduce both the transmission time and the amount of work that needs to be done on both ends of the line.
Enabling Gzip Compression in Apache
The Ubuntu and Debian system users follow the below steps to enable gzip compression in the Apache server.
- First of all, enable the mod_deflate module, which provides gzip compression to the Apache server.
sudo a2enmod deflate
- Once the module is enabled in the Apache server. Create or edit the
.htaccessfile in your website document root. For example, if the website document root is /var/www/html, then create file as:
sudo nano /var/www/html/.htaccess
- Use the following command to restart the Apache server.
sudo systemctl restart apache2
Verify Gzip Compression
Now that your site has been enabled with gzip compression, let’s use one of below online tools to verify that Gzip is working correctly.
GZIP compression is a technique that reduces the size of data sent over the network. This can be useful when sending large files over a slow connection, or when there is a lot of data to send. By compressing your data, you may be able to reduce the size of your transfer.
In this tutorial, you have learned about enabling Gzip compression in the Apache web server.