Top 3 Methods to Enable Gzip Compression in WordPress
Why Should We Enable Gzip Compression?
There are several benefits to enable Gzip compression because it’s the most popular method to load your site faster by reducing more than 70% page size of your blog. However, now-a-days most of the sites are using Gzip compression across the web. Gzip will load your site in just a few seconds.
Benefits
- Search more likely prefer you in search results
- Your server will no longer get large server requests to process
- 1000 KB page size will converted into 100KB
Time to time there have been developed several resources to enable Gzip for WordPress sites. There are 3 methods to enable Gzip compression in WordPress following are these:
[sociallocker]
[/sociallocker]
1. Enable Gzip using Existing (Maybe not) WordPress plugin W3 Total Cache
The most popular plugin (W3 Total Cache) which have a great role in improving your WordPress site performance, it also let you Gzip your site (To enable Gzip compression using w3 total cache, go to Performance > Browser Cache).
2. Enable Gzip Compression via .htaccess
Gzipping an easy way to reduce weight per page of your site. You can enable Gzip compression by adding the following code to your .htaccess file:
# compress text, html, javascript, css, xml: 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 AddType x-font/otf .otf AddType x-font/ttf .ttf AddType x-font/eot .eot AddType x-font/woff .woff AddType image/x-icon .ico AddType image/png .png
Don’t know how to edit .htaccess file directly from WordPress dashboard, click here.
3. WP HTTP Compression Plugin
This plugin allows you to output the pages in Gzip compressed format. HTTP compression generally means a 60-80% reduction in the size of your pages. Follow these steps to enable Gzip for WordPress:
1. Download, install and activate WP HTTP Compression
2. There is no settings page by this plugin because it works automatically, further see if your site is working after the installment of this plugin here =Â IS MY SITE WORKING.
TaDan! It’s Done!
I’d never heard about this method of making site’s faster. Thanks for this useful post.
I’m glad, if my article helped you..
Hi
Where should I add the following code to my .htaccess file (place) is there any specific place?
Hi thanks for the comment and letting me know about the issue. Let me tell you that there is not any specific way but you can add the line of codes just after the #END WordPress in your .htaccess file.
You should never add custom code in between the #BEGIN WordPress and #END WordPress lines.
WordPress automatically generates this section and any time you make modifications to something like Permalink settings, everything you’ve added between these lines will be overwritten.
Aha! Drew Hammond Thanks for you explanations.
I have been added it before End now my website is completely spoiled and not working shown 500 internal error even my wp directory also not working. please help me
Hi Xeshan Ali, let me know if you are using any caching plugin or minify plugin for CSS or JavaScript files.
Thanks Haroon,
Your post was really helpful.
thanks . its work very good
Very helpful, thanks a lot.
Your welcome @Peter Evans for stopping by…
Thanks for sharing Harron. Good content
our .htaccess instructions worked for me
Glad that you liked the article. I’m sure your site content is now GZIPPED using my codes đŸ™‚
very helpfull post Haroon. Thanks for sharing.
So I have enabled gzip with your code in the htaccess. I tested it with this tester and it worked.
However, PageSpeed is still telling me to enable it and telling me which files should be compressed. So do I need to compress the files for this to work? How do I do this? And if I compress the files can I not edit them in WordPress as usual? For example, it wants me to compress main.css
Thank you!
If you have just enabled the Gzip compression then why the pagespeed testing tool is asking you to enable compression on main.css? I’m using the same method to gzip my entire blog. In this case use wp-minify plugin to minify the CSS files only.
Thanks for the tip. I was getting a slow page speed at the Google Page Speed checker. After following your instructions I went from a 62 to an 87.
Your welcome @Alan. Thanks for sharing your views toward my article.
Thanks Muhammad, Thats what i was looking for ….
Thanks for the tip but do you know how to add expire headers in WordPress?
Your welcome @Hemant, and by the way I’ve also an article about how to add expires headers in WordPress. You can see it by clicking the link below:
https://softstribe.com/wordpress/how-to-add-expires-headers-in-wordpress/
Thanks for the tutorial. i add the code to htaccess and my page speed increase to 86%. Thanks
Well, Thanks for the positive reply @Malum…
thanks bro,
i will try to my project website, i hope this tutorial working done.
Your welcome..
Thanks for this code. would rather use code than plugins when I can.
Yeah! That would rather more better than using a plugin…
Enable Gzip Compression via .htaccess Like it !
Thx
Yeah! Hope that worked like a charm in your WordPress blog, @Amine… Your welcome by the way.
Hello, I don’t know why but when I active ZIP compression using htaccess I can’t see any page on the blog (I’m exploiting Super WP Cache too), but I just download a zip file without seeing anything. Any idea about this ? Thanks for you post đŸ™‚
Your welcome, If you are using WP Super Cache make sure that it’s setup correctly in your WordPress blog.
By the way, on adding the gzip codes in your .htaccess file the pages of your blog goes off as you said. Solution for this problem is that, you are using the multiple times compression options once the WP super cache compression option and the other one is by .htaccess file. You should use one time, rather than multiple, if you use multiple time compression option then they will conflict each other and the result would be the blank pages.
Regards,
Muhammad Haroon
Hello, you got the idea, it seems that WP Super Cache was also compressing my website files: so you should just choose, using htaccess manually or check plugin option for compression (and they say as notice, there is no WARRANCY that all will be ok).
Well, you got it right brother. You should only use the manual method and uncheck the option from WP Super Cache. It’s that easy solution for your problem.
Muhammad Haroon
worked great! Thanks a lot for the useful information! đŸ™‚
Your welcome.
Great post! I was already using the option “Compress pages so they’re served more quickly to visitors. (Recommended)” of wp-super cache checked. This option enables also enables gzip, but my grade was really bad on yslow and PageSpeed told me to make the gzip compression.
When I used your second method Google PageSpeed told me: You have compression enabled. And Yslow gave me a C Grade. 72% and 92% on GTmetrix.
Is there any problem using WP Super Cache method plus .htaccess from ur post?
Cya
Hey @Felipe BrandĂ£o,
Thank you for admiring my article, and by the way I’ve already told you guys about this problem here. Hope you doing well.
Nice, thnx! using step 2 my site jumped up 15 points on Google’s speed insight test.
Well @Herman Rosa, I know that. And many of people using this method as you did. By the way, your welcome and hope you doing well these days.
Awesome Info about gzip compression. i will apply this thing on my blog.
Thank you @Rizwan.
“2. Enable Gzip Compression via .htaccess
Gzipping an easy way to reduce weight per page of your site. You can enable Gzip compression by adding the following code to your .htaccess file:”
That simple, huh? When the host doesn’t allow mod_deflate, nothing will happen, right?
HI @Jeroen,
Yes, you are right. But still you can use the third way of enabling gzip compress:
3. WP HTTP Compression Plugin
This plugin allows you to output the pages in Gzip compressed format. HTTP compression generally means a 60-80% reduction in the size of your pages. Follow these steps to enable Gzip for WordPress:
1. Download, install and activate WP HTTP Compression
2. There is no settings page by this plugin because it works automatically, further see if your site is working after the installment of this plugin here = IS MY SITE WORKING.
TaDan! It’s Done!
Thanks Muhammad, I’m going give this a try since I have been spending hours on getting the gzip working via htaccess and W3 Total Cache (and other plugins)
Your welcome @Jeroen, keep visiting my blog. Sure you can give it try and by the way best of LUCK.
Thanks for the plugin Sir. But can I use this simple plugin? wordpress.org/plugins/wordpress-gzip-compression
Do check it out and please tell me! Thanks in advance.
Hi @Sohil Memon,
Thanks for the commment, and by the way manual process would be fine enough… Through .htaccess file, rather than using the third method of gzip compression… Okay. Hope you understand.
I added the code and my website speed did not increase at all? Am i doing something wrong? My speed from google is 52/100 its really hurting business
Well @Jared Del Re,
Let me know if you are using any caching plugin already on your blog? If so, please remove that plugin first.
The only one I had active was wp-optimize and its now removed, with no difference
No, it will rather not affect anything you can reactivate wp-optimize.
What else can we try? 52/100 load time is bt 8-10 seconds per page its horrible,
Yes, It’s really Horrible @Jared. But you still can use these 10 steps to score on Google Pagespeed for your WordPress blog.
https://softstribe.com/wordpress/10-steps-to-speed-up-wordpress
Hi Haroon, Thanks for sharing. It was really useful.
Thank you SO much for the Gzip compression code for the .htaccess file. I was running a 21/100 and 25/100 for mobile/desktop page load tests via PageSpeedTest insights on Google Developers. I’m now at 55/100 and 68/100 respectively. Your Gzip code fixed the majority of my slow response time. Now my host just needs to get their act together and get my server running more smoothly. Thanks so much.
That’s my pleasure @David.
Hello,
This is the article I have been looking for. Thanks for the information.
I added the code in my .htaccess. However, there is no difference in the speed test or google page speed test. What could be the problem, I really prefer the htaccess option
Do you think I should try to install WordPress plugin W3 Total Cache or the WP HTTP Compression Plugin? Do you have any preference
Hello
Thanks for the post.
I added the code that you provided to my .htaccess through ftp edit.
But, no change in the page speed.
Any suggestions
Hi @Riy, let me know if you are using any caching plugin…
Suggestion: Use only one either caching plugin or use the .htaccess codes…
hI
thanks for the reply
i am not using any caching plugin
Okay, in this case you use the 3rd method i.e, WP HTTP Compression Plugin. And remove the codes from .htaccess hope you this will work for your blog.
Hi,
I installed the w3 total cash and performance improved. Option 1. Thanks for that.
My question now is I want some pages not to be cached and I want to add it in the Never cache the following pages section
what is the format /my-account/* or my-account/* or the faq says something like /my-account/.+
appreciate your help
Just add the my-account/ …. For more details read this article:
https://softstribe.com/wordpress/resolved-never-cache-the-following-pages-w3-total-cache
Regards,
Muhammad Haroon
I use Total Cache plugin and hence i just need to sit back and relax.
Yeah, totally agreed with you @gujjufreak.
I do not want to use too many plugins, so I think I will enable GZip compression via htaccess
Yeah, it’s a pretty good idea @Cara Linda…
Thanks a lot, I put the code in my .htaccess file, and now my site is in 66% in Page Speed Insights, before it was 40%
Wow, that awesome William. Happy good Pagespeed day đŸ˜‰
Hey Muhammad, thanks a lot for your great post. I was just wondering: would you recommend doing all three of these methods at once – or should you only do one at a time? And if you should, which one method would you recommend the most?
Your welcome @James on my blog, but I recommend you to use one method at a time rather doing all at once. And by the way, the method that I would recommend you the one using .htaccess file. Hope you understand. Keep visiting my blog thanks.
Hello Haroon,
I have used .htaccess method for gzip compression on my blog. Thanks for sharing.
thanks for sharing. this method had help me to improve my website a lot.
Thanks, I used the second method to counter some non-compressed fonts on my server.
Went up by 4% page speed!
Thanks again.
Thanks for sharing. Good content
I used the Yoast SEO method you suggested. I got an increase of 13 points. It was simple, easy and worked. Yeah, you the man bro…
thank for your good sharing
Good content. Thanks sharing.
it really helped me lot.. Thanks for the post
Before this tips my site speed 10 second and now my site speed is 3sec đŸ™‚ Thanks for the post
Muito bom o artigo. So good. Thanks!
Excellent article. My problem solved. Thank you so much.
OMG, that you, i’ve been trying to compress this site for days and this WORKED!!! You are a star!!!!
My pleasure. Keep visiting đŸ™‚
Its so Helpfull for me, because my website day by day going to slow Thanks Softstribe Admin đŸ™‚
Your .htaccess instructions worked for me. Many thanks!
How to place gzip code in htaccess? thanks
You can just edit the htaccess file and put the codes after End WordPress comments in .htaccess file.
I was already using w3 cache plugin,which helped me load my site faster to some extent.Applied this method today and waiting for results.
Many Thanks for this, it has sped up our site considerably
Yes it does đŸ™‚ you are welcome pal.
Thanks … now my site is much faster.
I’m glad the codes helped you making your site gZipped and faster đŸ™‚
Your Post is very helpful and much appreciated.. thanks
Too good,
Thanks Haroon, via htaccess option is best worked for me. Thanks again bro.
Thanks a lot for sharing this wonderful tutorial or I would say article. It is the best plugin ever transfer google speed insight rank dramatically for me.
@Muhammad Haroon
Thanks… your article was very helpful.
I liked the way you have explained ..
Cheers,
Thanks … now my site is much faster.
Thanks for the article. It was very helpful.
Thanks for this awesome tutorial. I had my PageSpeed score from 71 to 79! That’s great!
Thanks again!
Nice tutorial, but how come you don’t have gzip compression enabled in your own site too? This page took forever to load.
Amazing after using gzip compression in my blog my blog website speed decrease form 5 second to 3.2 second. Thanks.
Thanks for this post, it helped to speed up my site considerably.
can not copy the codes because right click button is not working for your site… Help plz
Just fixed it. Sorry for inconvenience.
Thanks! Works like a charm đŸ˜€
some apache servers has a optimize website / compress content setting.
Will this work without the 3 methods above ??
No this won’t..
hi. I installed WP hTTP Compression plugin . Bt page insights still shows to enable compression. how do I eliminate this problem? It mentions specific files to compress.
How about you try any other alternative? Have you tried gzip htaccess code?
Great works, thanks for help.
im using gzip, but im tested at onpage org still not detected gzip. thats problem or not sir?
Th post was really helpful. Even though i use W3 total cache plugin, i was unaware that it is useful for compression as well.
Thank you very much.
You are more than welcome. Keep visiting and stopping by.
Hi,
Thanks dude for the great content. Enable gzip compression improve to load your site faster.
But I have installed the w3 total cache plugin and also added the above code into .htaccess file but still didn’t worked for me… please tell me how can do that??
Please either use the code provided in this article or use W3 Total Cache. Make sure you choose any one … don’t use both because they will break your site.
Awesome one broda! This guide helped me to make my site load faster. Thanks for the info!
Thanks for this awesome tutorial. I had my PageSpeed score from 81 to 89! That’s great! Thanks.
Thanks . It is working .
I have enabled Gzip compression using Total Cache. But GTMetrix still asks me to enable compression for a particular java script file. How can I do that ?
Thank you so much and its really solid ideas with very tricky but legal way. We just figured out few of our mistakes. Thanks again!
Perfect, I’ve tried with my website and it run very fast!!!
If you are using a cdn will that affect the performance of any plugins?
It shouldn’t. CDN just host static files in whole new link to make the site faster.
Thanks. It works perfectly