fbpx

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
</filesMatch>

[root@server ~]# systemctl restart httpd

References:
https://virtualmin.com/comment/768730
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-mod_deflate-on-centos-7

Share this article

Share on facebook
Share on twitter
Share on linkedin

Leave a Reply

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

Scroll to Top