Speed Up your WordPress Website using Compression in 5 minutes

Gzip Compression

WordPress is memory intensive and is a memory hog. The fact that it occupies lots of CPU resources and memory is nothing new. One of the best ways to optimize your WordPress website is by using compression.

What is Compression?

Compression can also be applied to websites just like files, folders are compressed in formats like .zip , .rar etc. In websites, HTTP compression, otherwise known as content encoding, is a publicly defined way to compress textual content transferred from web servers to browsers. HTTP compression uses public domain compression algorithms, like gzip and compress, to compress XHTML, JavaScript, CSS, and other text files at the server.

Most of my traffic comes from modern browsers, and quite frankly, most of my users are fairly tech-savvy. Google and Yahoo use gZip compression on their websites.

How to use GZip Compression in WordPress

Compression reduces response times by reducing the size of the HTTP response. Gzip is the most popular and effective compression method currently available and generally reduces the response size by about 70%. Approximately 90% of today’s Internet traffic travels through browsers that claim to support gzip.

If you want to take advantage of GZIP compression ( and we do recommend this ), then you WILL need an .htaccess file to accomplish that part. GZIP compression is something that should really be enabled at the Apache level or inside your php.ini file. GZIP compression can be used for things like JavaScript and CSS files as well, so why bother turning it on for only WordPress generated pages when you can enable GZIP at the server level and cover all the bases.

If your installation of Apache does not have mod_deflate installed. You can also enable GZIP compression using PHP configuration alone. In your php.ini file, you can simply add the following line anywhere: zlib.output_compression = on

Easiest Way to Enable GZip in WordPress

If you want to enable GZIP, in your WordPress installation directory put the following few lines in the .htaccess file and that is all there is to it. GZIP is now enabled!

GZip Compression Code WordPress

Download the Code here .

How to Check is GZip is working for your Website?

You can check if GZip is enabled on your WordPress using the a Free online tool at GZip Test. You can perform a GZip Compression Test using the Free online tool and see the results.

By using GZip Compression, we have been able to achieve around 76% compression.

We noticed considerable improvement in our Page load times after enabling the GZip compression. How about you?



{ 20 comments… read them below or add one }

1 raza rahil hussain May 15, 2010 at 4:21 pm

awesome article, now going to apply in my blog.

Reply

2 fareed May 15, 2010 at 5:22 pm

great tips thank you

Reply

3 Paritosh May 15, 2010 at 7:14 pm

You finally managed to get gzip working. Am still struggling, hope this helps :)

Reply

4 Packson in Delhi May 15, 2010 at 9:02 pm

I have read the same article on another blog, quickonlinetips.com. I am sure that you have copied text from there even without crediting to @pchere.

One question: do you think that the world is dumb? And, you are the most intelligent blogger.
Kid – grow up

Reply

5 Programming Kid May 15, 2010 at 9:27 pm

Hi!

If you feel this article is copied. Please provide the LINK of the website. If you think you can make false comments without properly looking into things objectively then you are mistaken. This article was written by me on 16 March 2010. If you can link the “said original article” from Quick Online Tips and prove that I have copied texts or lines. Then I would Delete this article.

Please Prove that this post is copied. Cached Google records, image Hotlinking, whatever. Now that you have commented. I want you to tell me and the readers from where has this article been copied from “Quick Online Tips”

Reply

6 Programming Kid May 15, 2010 at 9:39 pm

The Email you have provided is Invalid.
If you are sure of your claims, why have you posted anonymously?

I would like to hear from you.

Reply

7 Packson in Delhi May 15, 2010 at 10:16 pm

Ok dude. i am soooo sorry. here is the link to @qot http://www.quickonlinetips.com/archives/2010/05/leverage-browser-caching-increase-website-speed/

i just noticed that the codes are different. it is my mistake. sorry again.

You have written about gzip, and @qot wrote about browser caching. got it.

actually most of the kiddy bloggers (specially from India, Pakistan etc.) are spammers. they usually copy content/post ideas from others – and re-package. Well, you are not the one! Greets!

I’m a media worker (conventional media) based in New Delhi – and am observing trends among Indian bloggers. I’ve concluded so far that most of them (even those having good so-called reputation, and great stats – Alexa Adsense etc.) are spammers and thief.

Sorry again – and best of luck for future.

Reply

8 Programming Kid May 15, 2010 at 11:09 pm

I would like to add that most people like to come to conclusion too soon. The above incident goes to prove it.

Those who copy posts and ideas do not get too far with their blogs and fall out within 6 months.

Anyways, I am glad to know that you have compared the posts and agree that all works on this blog are original.

Thanks for stopping by.

Reply

9 Paritosh May 16, 2010 at 7:17 am

@Packson In Delhi I am amazed that being a media person you made allegations without even studying the facts carefully. Though, i am happy things are clear now. It saddening how content is copied without giving proper credit and i felt bad as an Indian blogger.

Reply

10 Editor, QuickOnlineTips May 16, 2010 at 8:46 am

Thanks for the nice article. I am glad all confusion is sorted out. We will use it to speed up our site. All the best.

Reply

11 Raju May 16, 2010 at 10:35 am

Thanks to you, I managed to come out of a weird problem. Even though I had enabled gzip compression on w3 total cache and also on my CDN, some of the gzip test tools like gidnetwork and YSlow were saying the content is not gzipped. Enabling mod_deflate and using the code you have given, I managed to gzip the content completely. I might not see huge improvements in terms of practical page load time, but I am hoping Google webmaster tool’s page speed performance shows an improvement now, will update here soon.

Reply

12 Programming Kid May 16, 2010 at 3:05 pm

Thanks for taking out time and trying out our tip on Gzip compression. Actually, I had screwed my theme many times before whenever I tried to do a gzip.

This method is relatively very simple. I also waiting for google webmaters to show the expected results.

The actual page load time drop would be clear in a dew days when google shows it in site performance.

All the best

Reply

13 Paritosh May 30, 2010 at 5:21 pm

Holy Cow…. It was such an easy task… Improved blog load time by almost 5 seconds… Sweet…

Reply

14 Neeraj Kumar June 19, 2010 at 9:43 am

Thanks for the tip. But i tried it on my webpage. I entered the code in my .htaccess file but, when i checked with gzip test tool, it shows the page is not compressed :(
any help ?

Reply

15 Harsh Agrawal July 24, 2010 at 2:24 am

Thanks for this Vaibhav. I have been using Super cache and I see it has an option to enable gZip compression but I never played with it. I checked using this tool and realize my site is not compressed. Going to enable gZip compression now.

Reply

16 vaibhav dugar September 13, 2010 at 12:30 pm

hey thanks for the post. after i installed firebug n then yslow, i was asked to compress using gzip.. stumbled upon yr post and implemented it in my .htaccess

then i headed over to the link that u provided, but it says that the webpage hasn’t been compressed. any idea?

Reply

17 vaibhav dugar September 13, 2010 at 12:56 pm

there’s another way:

Actually you don’t need a plugin to enable GZip Compression for WordPress. Simply do the following:

1. Login to your WordPress install as admin
2. navigate to http://www.yoursite.com/wp-admin/options.php
3. Scroll down to “gzipcompression” and change it’s field value to 1, which tells WordPress “true” for GZip Compression.
4. Click Save.

/wp-admin/options.php is “semi-hidden” options screen that will give you a break down of all definable options in your WordPress install. Some fields are editable and some or not for good reason.

Hope this helps!

Reply

18 Sanjay December 17, 2010 at 9:16 am

Great idea…….This Gzip thing is really speeding up for me. Please share more useful tips like this to speed up Wordpress,

Thanks.

Reply

19 TheShadow May 25, 2011 at 11:58 am

Thanks for the tutorial.You can also add by placing this code ob_start(“ob_gzhandler”); within loop in index.php .Only thing is you must add this when ever you update your wordpress version

Reply

20 Jay Wasack November 18, 2011 at 10:08 pm

I ran my two sites with the Gzip Compression tester site. I get a message “Unknown error.” How can I find out what error is?

Reply

Leave a Comment

Notify me of followup comments via e-mail. You can also subscribe without commenting.

{ 2 trackbacks }


WordPress - Vaibhav Kanwal