How to enable gZIP compression for your pages?

GZIP compression improves the performance of your website and decreases its loading time. When a visitor makes a request for your website, the server compresses the requested page, significantly reducing its size, and transfers it to the customer's computer. On the visitor's end the file is being decompressed and visualized. The time needed for file compression is much less than the time to transfer a big file over the Internet, thus compression enhances the performance of a website.

To enable GZIP compression for your text, html, JavaScript, CSS and XML you can add these lines inside the your website's  .htaccess file:

You can edit the .htaccess file with the File Manager in cPanel or via FTP.

Note that compression is disabled by default for SiteGround Staging instances. This means that the above .htaccess rules will have no effect and the compression will function as expected after the website is pushed live.

Note also that compression on server side will not work for remote resources that are loaded on the web page(such as remote CSS or Java Script inclusion for example). This is important as third party test tools(like GTMetrix) might not properly detect GZip compression as enabled.

Some applications also have internal support to compress their pages. For example, in Joomla you can turn on the Gzip compression from Global Configuration -> Server -> Gzip Page Compression set to Yes.

You find this article useful? Click here to learn more about SiteGround web hosting experts and what else we can do for you!