Website

How to Enable GZIP Compression to Speed Up Your Site

Do you want to make your site faster, increase SEO ranking, and attract more traffic? You can do it all by compressing your web files using the GZIP file format. Your website will take less space, and site speed might be improved.

Sounds interesting? Read on to find out how to enable GZIP compression on your site.

What Exactly is GZIP Compression?

GZIP compression is a popular method used to reduce the size of web files — including HTML, CSS, PHP, and JavaScript. That way, your site speed will improve, since visitors will download the compressed data instead of the full-sized files.

What’s more, Google includes page loading time as one of the factors in its ranking algorithm. The faster your site loads – the higher you’ll rank.

Considering the benefits of GZIP compression, it’s important to check whether your site has enabled it or not. You can use the Check GZIP Compression tool to do so.

If GZIP is already activated, the tool will show you the page size before and after the optimization. If it’s not, an error message will appear.

How to Enable GZIP Compression?

There are two methods of enabling GZIP compression: modifying the .htaccess file or using a WordPress plugin, like WP Rocket.

Using a WordPress Plugin

The easiest way to enable GZIP compression in your WordPress site is to install a plugin. It will be a lot easier and safer than modifying the .htaccess file.

There are a lot of plugin choices available, but we have singled out these three plugins based on their features and ease of use:

  • WP-Optimize — an all-in-one solution to boost your website performance. The plugin will enable GZIP compression and web caching. In addition to that, it will clean unnecessary files on your website. This tool can even optimize images to free up more space!
    WP-Optimize GZIP compression plugin for WordPress
  • Hummingbird — you have more freedom to choose what aspects you want to optimize. GZIP compression, minification, and lazy load offscreen images are some of its main features.
    Hummingbird GZIP compression plugin for WordPress
  • WP Fastest Cache — WP Fastest Cache combines its caching prowess with GZIP compression to make your page fast and lightweight. This tool can also automatically disable emojis and optimize every single post.
    WP Fastest Cache GZIP compression plugin for WordPress

Since these plugins can do so much more than enabling GZIP compression, I suggest that you try all of them to see which one fits you best. After all, they are free and frequently updated, what’s not to love?

Adding Code to the .htaccess File

This method is quite technical, so it’s more suitable for advanced users. However, anyone can do it as long as they are careful.

Before we continue, remember that you should always back up your .htaccess file first in case something goes wrong.

  1. You will need to download an FTP client, like Filezilla, to locate the .htaccess file. It is usually placed in the public_html directory of your website.
    Where to find .htaccess file using FileZilla
  2. Download the file and save a copy on your computer as a backup. Then, paste the following code before # END WordPress line of .htaccess.
    <IfModule mod_deflate.c>
    
    AddOutputFilterByType DEFLATE text/plain
    
    AddOutputFilterByType DEFLATE text/html
    
    AddOutputFilterByType DEFLATE text/xml
    
    AddOutputFilterByType DEFLATE text/css
    
    AddOutputFilterByType DEFLATE application/xml
    
    AddOutputFilterByType DEFLATE application/xhtml+xml
    
    AddOutputFilterByType DEFLATE application/rss+xml
    
    AddOutputFilterByType DEFLATE application/javascript
    
    AddOutputFilterByType DEFLATE application/x-javascript
    
    </IfModule>
  3. Upload the edited file to the same location. If FileZilla asks permission to overwrite it, click OK.

Now, if you use the Check GZIP Compression tool again, the results should look like this:

Test results when you enable GZIP compression on your site.

 

Conclusion

GZIP compression reduces the size of your pages and speeds up your site. As a result, visitors will have a great user experience and your site can rank well in SERP.

You can easily enable GZIP compression on your site by using two methods: either installing a WordPress plugin or editing the .htaccess file. Here’s a summary on how to do that:

  • Via a plugin. Choose one of the plugins that we recommend and install it on your WordPress site. Go to the plugin’s settings page, and then run the automatic optimization.
  • Via .htaccess file. Use FileZilla to locate the .htaccess file, and then add the code that we have provided. Upload the file to your website directory and overwrite the old one.

Pretty easy, right? Let us know in the comments if you have any questions!

About the author

Irfan F.

Irfan is a member of the Digital Content Writer team at Hostinger. He believes that technology and the internet can help improve our lives significantly. That's why he shares his experience as a WordPress blogger to educate others. In his free time, Irfan enjoys good films and books.

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!

More in Website
Improving Website Performance – Using Progressive JPEG images

Close