Setting compression of web pages using CPanel, including wordpress files

If you run a “Performance” audit on your webpage, either using the stand-alone Google Lighthouse extension or by using the Audit option of Chrome, Google will present to you “Opportunities” to improve page load speed. If your files are not “Compressed”, Google will always present “Compression” to you as an opportunity.

How does compression work?

Compression is an algorithmic way to compress a file by reducing redundant data in a file and then by adding it back in when the file is uncompressed. When modern browsers send a an HTTP Request to the server, they will send the header “accept-encoding”. This is typically, “gzip, deflate”. This tells the server that it is safe to compress a file before sending it to you and thus reducing the time needed for the browser to load the file. Your browser will uncompress the file upon receiving it. The time it needs to uncompress a file is much less than the time it would take to receive the uncompressed file, and so your page loads much faster.

Compressing with CPanel

If you are using Linux with CPanel, you can easily enable compression. First, from CPanel, choose Software > Optimize Website. There you can optimize all content except PHP scripts. Your hosting company must have enabled Apache’s mod_deflate for this to work. Always choose a hosting company that supports this option.

If you also have PHP scripts – for example, if you are using WordPress- , then next go to Software > Select PHP Version. On the right side of that panel, choose Switch to PHP Options. Scroll down to zlib.output_compression and set this to “on”.

Leave a Reply

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