|

Top 3 Methods to Enable Gzip Compression in WordPress

No votes yet.
Please wait...

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

  1. Search more likely prefer you in search results
  2. Your server will no longer get large server requests to process
  3. 1000 KB page size will converted into 100KB

Enable Gzip Compression

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:

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).

Enable Gzip via W3 Total 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!

Similar Posts

126 Comments

  1. I’d never heard about this method of making site’s faster. Thanks for this useful post.

    No votes yet.
    Please wait...
    1. I’m glad, if my article helped you..

      No votes yet.
      Please wait...
  2. Hi
    Where should I add the following code to my .htaccess file (place) is there any specific place?

    No votes yet.
    Please wait...
    1. 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.

      No votes yet.
      Please wait...
      1. 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.

        No votes yet.
        Please wait...
        1. Aha! Drew Hammond Thanks for you explanations.

          No votes yet.
          Please wait...
      2. 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

        No votes yet.
        Please wait...
        1. Hi Xeshan Ali, let me know if you are using any caching plugin or minify plugin for CSS or JavaScript files.

          No votes yet.
          Please wait...
  3. Thanks Haroon,

    Your post was really helpful.

    No votes yet.
    Please wait...
  4. thanks . its work very good

    No votes yet.
    Please wait...
  5. Very helpful, thanks a lot.

    No votes yet.
    Please wait...
    1. Your welcome @Peter Evans for stopping by…

      No votes yet.
      Please wait...
      1. Thanks for sharing Harron. Good content
        our .htaccess instructions worked for me

        No votes yet.
        Please wait...
        1. Glad that you liked the article. I’m sure your site content is now GZIPPED using my codes 🙂

          No votes yet.
          Please wait...
  6. very helpfull post Haroon. Thanks for sharing.

    No votes yet.
    Please wait...
  7. 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!

    No votes yet.
    Please wait...
    1. 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.

      No votes yet.
      Please wait...
  8. 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.

    No votes yet.
    Please wait...
    1. Your welcome @Alan. Thanks for sharing your views toward my article.

      No votes yet.
      Please wait...
  9. Thanks Muhammad, Thats what i was looking for ….

    No votes yet.
    Please wait...
  10. Thanks for the tip but do you know how to add expire headers in WordPress?

    No votes yet.
    Please wait...
    1. 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/

      No votes yet.
      Please wait...
  11. Thanks for the tutorial. i add the code to htaccess and my page speed increase to 86%. Thanks

    No votes yet.
    Please wait...
    1. Well, Thanks for the positive reply @Malum…

      No votes yet.
      Please wait...
  12. thanks bro,
    i will try to my project website, i hope this tutorial working done.

    No votes yet.
    Please wait...
    1. Your welcome..

      No votes yet.
      Please wait...
  13. Thanks for this code. would rather use code than plugins when I can.

    No votes yet.
    Please wait...
    1. Yeah! That would rather more better than using a plugin…

      No votes yet.
      Please wait...
  14. Enable Gzip Compression via .htaccess Like it !
    Thx

    No votes yet.
    Please wait...
    1. Yeah! Hope that worked like a charm in your WordPress blog, @Amine… Your welcome by the way.

      No votes yet.
      Please wait...
  15. 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 🙂

    No votes yet.
    Please wait...
    1. 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

      No votes yet.
      Please wait...
      1. 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).

        No votes yet.
        Please wait...
        1. 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

          No votes yet.
          Please wait...
  16. worked great! Thanks a lot for the useful information! 🙂

    No votes yet.
    Please wait...
    1. Your welcome.

      No votes yet.
      Please wait...
  17. 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

    No votes yet.
    Please wait...
    1. 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.

      No votes yet.
      Please wait...
  18. Nice, thnx! using step 2 my site jumped up 15 points on Google’s speed insight test.

    No votes yet.
    Please wait...
    1. 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.

      No votes yet.
      Please wait...
  19. Awesome Info about gzip compression. i will apply this thing on my blog.

    No votes yet.
    Please wait...
    1. Thank you @Rizwan.

      No votes yet.
      Please wait...
  20. “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?

    No votes yet.
    Please wait...
    1. 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!

      No votes yet.
      Please wait...
      1. 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)

        No votes yet.
        Please wait...
        1. Your welcome @Jeroen, keep visiting my blog. Sure you can give it try and by the way best of LUCK.

          No votes yet.
          Please wait...
  21. 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.

    No votes yet.
    Please wait...
    1. 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.

      No votes yet.
      Please wait...
  22. 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

    No votes yet.
    Please wait...
    1. 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.

      No votes yet.
      Please wait...
      1. The only one I had active was wp-optimize and its now removed, with no difference

        No votes yet.
        Please wait...
        1. No, it will rather not affect anything you can reactivate wp-optimize.

          No votes yet.
          Please wait...
          1. What else can we try? 52/100 load time is bt 8-10 seconds per page its horrible,

            No votes yet.
            Please wait...
          2. 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

            No votes yet.
            Please wait...
  23. Hi Haroon, Thanks for sharing. It was really useful.

    No votes yet.
    Please wait...
  24. 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.

    No votes yet.
    Please wait...
    1. That’s my pleasure @David.

      No votes yet.
      Please wait...
  25. 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

    No votes yet.
    Please wait...
  26. 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

    No votes yet.
    Please wait...
    1. Hi @Riy, let me know if you are using any caching plugin…

      Suggestion: Use only one either caching plugin or use the .htaccess codes…

      No votes yet.
      Please wait...
  27. hI
    thanks for the reply
    i am not using any caching plugin

    No votes yet.
    Please wait...
    1. 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.

      No votes yet.
      Please wait...
      1. 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

        No votes yet.
        Please wait...
        1. 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

          No votes yet.
          Please wait...
  28. I use Total Cache plugin and hence i just need to sit back and relax.

    No votes yet.
    Please wait...
    1. Yeah, totally agreed with you @gujjufreak.

      No votes yet.
      Please wait...
  29. I do not want to use too many plugins, so I think I will enable GZip compression via htaccess

    No votes yet.
    Please wait...
    1. Yeah, it’s a pretty good idea @Cara Linda…

      No votes yet.
      Please wait...
  30. 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%

    No votes yet.
    Please wait...
    1. Wow, that awesome William. Happy good Pagespeed day 😉

      No votes yet.
      Please wait...
  31. 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?

    No votes yet.
    Please wait...
    1. 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.

      No votes yet.
      Please wait...
  32. Hello Haroon,

    I have used .htaccess method for gzip compression on my blog. Thanks for sharing.

    No votes yet.
    Please wait...
  33. thanks for sharing. this method had help me to improve my website a lot.

    No votes yet.
    Please wait...
  34. Thanks, I used the second method to counter some non-compressed fonts on my server.

    Went up by 4% page speed!

    Thanks again.

    No votes yet.
    Please wait...
  35. Thanks for sharing. Good content

    No votes yet.
    Please wait...
  36. 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…

    No votes yet.
    Please wait...
  37. thank for your good sharing

    No votes yet.
    Please wait...
  38. Good content. Thanks sharing.

    No votes yet.
    Please wait...
  39. it really helped me lot.. Thanks for the post

    No votes yet.
    Please wait...
  40. Before this tips my site speed 10 second and now my site speed is 3sec 🙂 Thanks for the post

    No votes yet.
    Please wait...
  41. Muito bom o artigo. So good. Thanks!

    No votes yet.
    Please wait...
  42. Excellent article. My problem solved. Thank you so much.

    No votes yet.
    Please wait...
  43. OMG, that you, i’ve been trying to compress this site for days and this WORKED!!! You are a star!!!!

    No votes yet.
    Please wait...
    1. My pleasure. Keep visiting 🙂

      No votes yet.
      Please wait...
  44. Its so Helpfull for me, because my website day by day going to slow Thanks Softstribe Admin 🙂

    No votes yet.
    Please wait...
  45. Your .htaccess instructions worked for me. Many thanks!

    No votes yet.
    Please wait...
  46. How to place gzip code in htaccess? thanks

    No votes yet.
    Please wait...
    1. You can just edit the htaccess file and put the codes after End WordPress comments in .htaccess file.

      No votes yet.
      Please wait...
  47. 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.

    No votes yet.
    Please wait...
  48. Many Thanks for this, it has sped up our site considerably

    No votes yet.
    Please wait...
    1. Yes it does 🙂 you are welcome pal.

      No votes yet.
      Please wait...
  49. Thanks … now my site is much faster.

    No votes yet.
    Please wait...
    1. I’m glad the codes helped you making your site gZipped and faster 🙂

      No votes yet.
      Please wait...
  50. Your Post is very helpful and much appreciated.. thanks

    No votes yet.
    Please wait...
  51. Too good,

    Thanks Haroon, via htaccess option is best worked for me. Thanks again bro.

    No votes yet.
    Please wait...
  52. 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.

    No votes yet.
    Please wait...
  53. @Muhammad Haroon
    Thanks… your article was very helpful.
    I liked the way you have explained ..

    Cheers,

    No votes yet.
    Please wait...
  54. Thanks … now my site is much faster.

    No votes yet.
    Please wait...
  55. Thanks for the article. It was very helpful.

    No votes yet.
    Please wait...
  56. Thanks for this awesome tutorial. I had my PageSpeed score from 71 to 79! That’s great!
    Thanks again!

    No votes yet.
    Please wait...
  57. Nice tutorial, but how come you don’t have gzip compression enabled in your own site too? This page took forever to load.

    No votes yet.
    Please wait...
  58. Amazing after using gzip compression in my blog my blog website speed decrease form 5 second to 3.2 second. Thanks.

    No votes yet.
    Please wait...
  59. Thanks for this post, it helped to speed up my site considerably.

    No votes yet.
    Please wait...
  60. can not copy the codes because right click button is not working for your site… Help plz

    No votes yet.
    Please wait...
    1. Just fixed it. Sorry for inconvenience.

      No votes yet.
      Please wait...
  61. Thanks! Works like a charm 😀

    No votes yet.
    Please wait...
  62. some apache servers has a optimize website / compress content setting.

    Will this work without the 3 methods above ??

    No votes yet.
    Please wait...
    1. No this won’t..

      No votes yet.
      Please wait...
  63. 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.

    No votes yet.
    Please wait...
    1. How about you try any other alternative? Have you tried gzip htaccess code?

      No votes yet.
      Please wait...
  64. Great works, thanks for help.

    No votes yet.
    Please wait...
  65. im using gzip, but im tested at onpage org still not detected gzip. thats problem or not sir?

    No votes yet.
    Please wait...
  66. 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.

    No votes yet.
    Please wait...
    1. You are more than welcome. Keep visiting and stopping by.

      No votes yet.
      Please wait...
  67. 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??

    No votes yet.
    Please wait...
    1. 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.

      No votes yet.
      Please wait...
  68. Awesome one broda! This guide helped me to make my site load faster. Thanks for the info!

    No votes yet.
    Please wait...
  69. Thanks for this awesome tutorial. I had my PageSpeed score from 81 to 89! That’s great! Thanks.

    No votes yet.
    Please wait...
  70. Thanks . It is working .

    No votes yet.
    Please wait...
  71. 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 ?

    No votes yet.
    Please wait...
  72. 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!

    No votes yet.
    Please wait...
  73. Perfect, I’ve tried with my website and it run very fast!!!

    No votes yet.
    Please wait...
  74. If you are using a cdn will that affect the performance of any plugins?

    No votes yet.
    Please wait...
    1. It shouldn’t. CDN just host static files in whole new link to make the site faster.

      No votes yet.
      Please wait...
  75. Thanks. It works perfectly

    No votes yet.
    Please wait...

Leave a Reply

Your email address will not be published. Required fields are marked *