How to enable gzip compression on an Apache server

Background

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:

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

[[email protected] ~]# systemctl restart httpd

See Also

How to enable gzip compression on an NGINX server

References

Share this article

Leave a Reply

Your email address will not be published.

Scroll to Top