GZip compression is a powerful tool for reducing loading times, and it works by decreasing the size of the files sent from your server.
Hopefully, if you’re reading this, you understand how important it is to reduce loading times, and how much improvement it can make in your site’s image. In fact, it’s been shown in various credibility studies that fast loading times are one of the highest factors in affecting a site’s perception of credibility.
That’s why we’re going to discuss GZip compression and how to enable it, either by using htaccess or cPanel.
The Basics of GZip
GZip uses an extremely simple compression method to reduce page sizes. It simply locates strings of text in a file that are similar to each other, and replaces them with a placeholder — the whole process can reduce overall file size by up to 70%.
GZip works so well because scripting files like CSS and HTML tend to repeat a lot of their tags over and over again, adding unnecessary size to the files being sent over.
Enabling Compression Using the .htaccess File
One way to enable GZip is to open the .htaccess file and insert some code to direct it to compress certain tags in the file.
The following code is effective for enabling compression and can be inserted directly into the file at any location, preferably at the beginning of the file.
<ifmodule mod_deflate.c> AddOutputFilterByType DEFLATE text/text text/plain text/html text/xml text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
After inserting this code, simply save your file and reload a page to test. Compress should now be enabled.
Enabling GZip Using CPanel
If you’d rather not modify your .htaccess file, or if you just happen to be using CPanel and you’d like to know an easier way to change the GZip settings on your pages, you can follow the instructions below.
- From the Home page of cPanel, look for a link that says Software/Services. Click that link.
- After being redirected to the following page, look for a link that says Optimize Website. Click that link.
- On this page, you can disable or enable compression of your site’s content. Simply select the Disabled option or the Compress all content option.
- Click Update Settings.
You can also choose to compress only certain types of content using the Compress the specified MIME types option. Just enter the media types you’d like to compress in the text box and click Update Settings. If you’re not sure how to specify which types you want to compress, look for more information at this Wikipedia page.
It’s worth noting that you shouldn’t add image types to this field because image files are already compressed.
Regardless of which option you choose, you’ll definitely be able to reduce bandwidth usage and save your visitors time on your website.
The only last concern you may want to consider is whether you have high numbers of visitors, as the extra time that your server spends compressing these files can really add up on the server side. If you’re serving fewer than thousands of visitors a day, however, it won’t be a problem, and you can simply use GZip compression to save your visitors time.
If you want to see the impacts of enabling GZip compression for your website, you can take the website speed test before and after.