How to enable gzip compression on an Apache server


Numerous sites that test web server speed refers to ‘compression on the server’. The idea behind this compression is that the server compresses certain files before sending it to the client (the browser). On the client side these files are again decompressed. Although there is a overhead on the client side to decompress file, this is marginal compared to the potential network savings.

In order to enable compression you need to configure Apache. If you’re using CentOS 7 the following configuration will compress Javascript, HTML, and CSS files:

[root@server ~]# vi /etc/httpd/conf.d/mod_deflate.conf
<filesMatch "\.(js|html|css)$">
    SetOutputFilter DEFLATE

[root@server ~]# systemctl restart httpd

See Also

How to enable gzip compression on an NGINX server


Share this article

Leave a Reply

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

Scroll to Top