How to Enable GZIP Compression in WordPress via .htaccess

>How to Enable GZIP Compression in WordPress via .htaccess
  • .gz gzip

If – for whatever reason – you’re not using a caching plugin, such as (affiliate link) WP Rocket (review) or W3 Total Cache, or you’re using one, but for some reason, the gzip compression feature is not working, then you can enable it manually in your .htaccess file.

For example, when I set up a light WordPress website or blog for a client, and he/she is using (affiliate link) SiteGround hosting (review), I prefer using their SG Optimizer plugin, in case the client doesn’t want to use or can’t afford WP Rocket.

But the SG Optimizer plugin doesn’t enable gzip compression by default, so I have to add it manually.

Before showing you how to enable gzip compression in WordPress using the .htaccess file, let me briefly tell you what it is.

What is GZIP compression?

When a user visits your website, the server has to deliver the files in order to display the website.

Now, the bigger the files, the longer it will take them to reach the user’s browser to display the website.

By enabling gzip compression, the files will get compressed before reaching your browser, making them smaller, therefore improving the delivery time.

Enable gzip compression in WordPress using .htaccess

I recommend backing up the file or the entire website first! Also, for the gzip compression to work, you’ll need to have mod_deflate enabled on your server! If it’s not, then you have to talk to your web host.

Step 1 – Access your website’s .htaccess file

edit .htaccess in capenl

Editing .htaccess in cPanel

You’ll need to access the .htaccess file of your WordPress website, which should normally be in the root folder – /public_html/.htaccess.

If you’re using an add-on domain, not the main one, then you should look in /YOURDOMAIN/public_html/.htaccess.

Here’s how to access your WordPress website’s files.

Step 2 – Add the gzip compression code

Copy the below code and paste it in the .htaccess file, right before the #BEGIN WordPress line.

Copy to Clipboard

Here’s how it looks like on my end:

enable gzip compression .htaccess wordpress

Don’t forget to save the file!

That’s it!

You can use this tool to see if you have successfully enabled gzip compression for your WordPress website.

You might also need to enable browser caching in WordPress via .htaccess if you don’t have it already.

That’s a wrap

I hope you found the post useful and comprehensive!

Don’t forget to share the post to help out others!

You can quickly subscribe to my newsletter by using this link.

If you have any questions or thoughts, drop a comment or send a message via contact or Facebook page.

You can also hit the follow button on Twitter and subscribe to the YouTube channel.

My WordPress installation service is at your disposal!

On-going WordPress support and maintenance services are on the menu as well!

WP Rocket - WordPress Caching Plugin
By |2018-11-20T21:23:38+00:00November 14th, 2018|Tips|0 Comments

Leave A Comment

SUBSCRIBE BEFORE YOU GO?

- Get guides and offers right into your inbox -

The type of emails that you would like to receive (multiple selection allowed):

You can unsubscribe at any time by clicking the link in the footer of the emails. For more information, please check the privacy policy.

I use MailChimp as my emailing service. By subscribing, you understand that your email and preferences will be transferred to MailChimp. Learn more about MailChimp's privacy practices here.

close-link