cpu-load

WordPress is known to be resource intensive and memory intensive blogging platform. Without optimizing, if you use WordPress “as-is” you are bound to face the wrath of your host, eventually resulting in the website downtime.

In case you have a heavy theme with lots of images, JavaScripts, CSS etc, you would be needed to worry about “Bandwidth” as well. Everytime you type www.techpp.com into your browser to read this blog, the browser sends a request to the server located at www.techpp.com to get the content. The server reads the request, processes it and sends back the requested data back to the browser.

For example, if you request a web page that is 25,024 bytes long, the web server sends the entire 25,024 bytes to the browser. In other words, the data is sent in its “raw” or “natural” form.

Data Encoding / Data Compression

Almost all the web-browsers these days are capable of sending a parameter Accept-Encoding as a part of the header request. This tells the web server that the browser can accept encoded/compressed data as well. If the server so chooses, it selects one of the encodings that the browser supports (the browser sends a list of supported encodings) and compresses the data with the selected encoding algorithm. Instead of sending a 25,024 byte document in the example above, it might end up sending a 10,567 byte long document which is a significantly lesser data transfer.

GZIP Encoding

“GZIP” or “gzip” refers to compression/decompression algorithm used by the gzip application (gzip application is used to compress and decompress data on UNIX/Linux machines).

A web browser that understands gzip encoding sends an Accept-Encoding header that looks like this:

Accept-Encoding: gzip

The web server encodes the data using the gzip algorithm and sends back the appropriate Content-Encoding header:

Content-Encoding: gzip

The browser then uses the gzip decoding algorithm to return the data to its normal, uncompressed form.

How GZIP encoding saves bandwidth and improves performance?

The idea behind gzip encoding is to reduce the amount of data being transferred over the network. In the example above, the size of the data was reduced by over half. Not only does the data transmit more quickly, bandwidth consumed will be less as well.

Gzip compression and WordPress

I hardly have much knowledge on WordPress core files. From whatever I know, in WordPress 2.8 beta, hooks for gzip encoding have been provided for the plugin/theme designers. But I believe GZip encoding and compression should be enabled by default within WordPress core (which I believe is not the case right now).

Plugins like wp-super-cache provide this feature to gzip the content, which in turn compresses the data (js and CSS) and ensure better performance and lower bandwidth usage. But why a plugin must be doing this? Why not it be a feature in WordPress?

I request people who know about WordPress to comment on this and correct me if I am wrong anywhere.

Free subscription: Subscribe to RSS feed or get daily tips in your email
You must click confirmation link sent in email. If you don't see the email, check the spam folder

Around the Web:

Raju Raju is the owner and editor-in-chief of TechPP. A proud geek and an Internet freak, who is also a social networking enthusiast. You can follow him on Twitter @rajupp

View Comments so far | Have Your Say!

  1. Raju,

    Nice post. I am on the same boat as you are.

    But, i have a question. If we enable gzip compression. Does every request not make extra burden on hosting service. which needs to first gzip it and then send the data to the client?

    Nihars last blog post..How to Block Visitors / Traffic from a Specific Country

  2. I’m curious, while GZip would decrease bandwidth concerns wouldn’t it increase CPU usage?

    Christopher Rosss last blog post..Google articles in the news

  3. I don’t have any knowledge about all these technical stuffs, but what I experienced with my previous theme (the complete version of the existing one) was that the gzip compression screwed the appearance of my blog badly, then I remove it. First I need to test WP latest version on localhost before I use it on live website.

    Pavan Kumars last blog post..What Search Engines Think of “Search Engine”?

  4. @Nihar,
    Its not every request, only the first request will have the content g-zipped, for the following requests, it will serve the already compressed data directly (thereby saving CPU resources)

    @Ross,
    It doesn’t increase CPU usage (assuming you don’t clear the cache too frequently)

    @Pavan,
    I do not know what was wrong with your theme, Possibly CSS compression was not done properly, but it works perfectly fine in my themes

  5. I had not tried it but heard about many time from my friends. After reading you article I thinks that why don’t have try it. its seems very useful.

  6. Well, I use YSlow Plugin by Yahoo with Firebug. I tested it on your site and it gave your site 53 marks (Grade E), though your site loads in 7.674 seconds.
    It also tells to compress components with gzip.. but I have no idea about it :-( .

    Gautams last blog post..Create Your Personalized Yahoo! Messenger and Chat With Your Friends on Orkut

  7. After reading through your article I’m tempted to try out your suggestion. But the issue is that I’m not certain what the outcome will be with the present theme that I am using. Some friends claim the theme may go haywire if it is not standardized.

  8. I strongly support your suggestion for enabling the transfer of compressed data. Most of the current browsers do support gzip and I don’t find any reason why it shouldn’t be a part of wordpress core library code.

  9. I’m doing my research on Optimizing Wordpres and many people has written about gZip. though many people prefer other techniques and before implementing gZip into my blog, I wanna see..what other users review are saying…

  10. Hi
    Just took a look in my Google Webmaster Tools and spotted that it now gives you data on page load times.
    All of my html sites are super fast… my WordPress site is super slow.
    So Im looking for ways to speed it up… hence finding this post.

    I read somewhere that Google uses page load speed as one of its pagerank metrics. So I have to improve the page speed.

    Looks like I might be uploading the super-cache plugin!

  11. I once has concern that download time reduction might not deserver CPU consumption time.

    I did some experimentation with Debug Queries plugin. It shows that CPU time is always small fraction time of page load cycle. So, we’d better have gzip enabled.

  12. Hey buddy thanks for your article but I didn’t feel i got to learn how to do this. I couldn’t use Wp Suer Cache as it messed with my .htaccess too much and then it wouldn’t work. I now use Hyper Cache but it doesn;t seem to enable gzip at least not according to Google Webmaster tools. Can you guide me to doing this. I’m with hostgator on shared hosting. I will subscribe to this comment. Hope to hear back soon. THanks very much. Mark

  13. those who don’t feel like enbling wp-super-cache

    check : http://ilfilosofo.com/blog/2008/02/22/wordpress-gzip-plugin/

    hope that helps.

  14. Hunter Satterwhite

    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!

    • Wow!! I never knew this! May be I should try playing around this on my other (smaller) sites, not sure if it has some side-effects. Thanks Hunter!

  15. thanks hunter for this info i didn’t knew about this and direct option was not visible in wordpress hence went the plugin way.

    thanks for reducing one more hook for my wordpress install.

  16. Thanks Hunter…glad to eliminate the need for one more plugin.

  17. I am going to try that wp-options.php method. Hope there are no side effects. Thanks Hunter.

  18. i tried to do this, but i cannot fix the setting,
    thanks for the info

  19. Hello every body,

    I did as Mr.Hunter said, but gzip did not work ! I made a test to know whether It is working as Mr.Hunter said or not :

    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.

    Then I visit this site for free test and I am afraid that what Mr.Hunter said is wrong :(
    For testing gzip on your site :
    http://www.gidnetwork.com/tools/gzip-test.php

    Then I used a plugin and re test my site :) Yes, gzip Working
    The Plugin :
    http://wordpress.org/extend/plugins/wpcompressor/

    Thanks anyway

Trackbacks/Pingbacks

blog comments powered by Disqus
Copyright 2010 Technically Personal! 
Blog Design Studio