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.

Subscribe via RSS or Email:
Raju is the founder-editor of Technically Personal. A proud geek and an Internet freak, who is also a social networking enthusiast. You can follow him on Facebook and on Twitter. Mail Raju PP.
  • http://www.niharsworld.com/ Nihar

    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

  • http://www.thisismyurl.com/tutorials/make-money-online/make-money-online-with-google-adsense/ Christopher Ross

    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

  • http://www.techpavan.com Pavan Kumar

    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”?

  • Pingback: » GZip Compression and bWordpress/b - bandwidth usage, data compression b…/b Wordpress UK: Wordpress UK, taking it further…

  • http://techpp.com Raju

    @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

  • http://www.snoopstation.com Public Records

    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.

  • http://www.orkutplus.net/ Gautam

    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

  • http://naijacomputers.com Business Computers

    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.

  • http://mohanbn.com/blog/ Mohan

    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.

  • http://www.shoutmeloud.com Harsh Agrawal

    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…

  • http://easypublicspeaking.co.uk/ Keith Davis

    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!

  • http://www.morgancheng.com Morgan Cheng

    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.

  • Mark

    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

  • http://blog.anantshri.info Anant Shrivastava

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

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

    hope that helps.

  • 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!

    • http://techpp.com Raju

      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!

  • http://blog.anantshri.info Anant Shrivastava

    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.

  • http://www.ilovephotoblogs.com rick

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

  • http://in.linkedin.com/in/santoshbhandarkarindia Santosh Bhandarkar

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

  • http://www.juliandika.com julian

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

  • Noor

    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

  • http://tonyfraga.com Tony

    I will try this, only after more research. If is does disrupt the site, can it be easily fixed?

    • http://techpp.com Raju

      as a thumb rule, back up your site (everything including database) before making any change

  • Pingback: How To Enable GZIP Compression For Your WordPress Site | Do It Yourself Web Server / Hosting

  • David

    Not that I’m much better, but you don’t have many wordpress experts following your blog. Or your keywords are perfect for beginners’ searches.

    Explination:
    http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

    Why it’s better as a plugin v. htaccess customized, and why it’s not included, not sure. But I’m sure google will answer me soon enough.

    PS W3 Total cache is now the “standard” for caching plugins. It one-ups supercache.

    For Speed, a CDN helps a lot:
    Search for cloudflare for their site

    Article about it:
    pbjbreaktime.com/2011/01/cloudflare-speeds-website/

    • http://techpp.com Raju PP

      >> Not that I’m much better
      huh? better in what way?

      >> but you don’t have many wordpress experts following your blog.
      Thanks. I didn’t know that.

      >> Or your keywords are perfect for beginners’ searches.
      Not just the keywords, the article as a whole is aimed at beginners. The article you linked to is full of jargons and messy details.

      >> W3 Total cache is now the “standard” for caching plugins. It one-ups supercache.
      Agreed.

  • Roell

    Thanks Raju for make this post, Not only from your advice, but many of your comentator is useful for me to speed my website

  • x0ajzah327

    Enables gzip-compression if the visitor’s browser can handle it. This will speed up your WordPress website drastically and reduces bandwidth usage as well. Uses the PHP ob_gzhandler() callback.

  • Name (required)

    I am in the process of switching to a VPS server, and I am previewing everything before I go live on the new nameservers. I know the mod_deflate extension is activated, so I should be able to send everything compressed. However, my pages will not compress! Here is what I have in my .htaccess file:

    AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript

    However, everytime I check YSlow and PageSpeed it tells me that my page is not compressed. It is bugging the fool out of me. What can I do to get my pages compressed?

    Does it have something to do with there not being any .html or whatever on the end of my adresses?

  • http://mobilethemesworld.net/ TheShadow

    Hi,Thanks for letting us know.You can also enable gzip by adding code to index.php page

    ob_start(“ob_gzhandler”); place this within the loop

  • Vaibhav

    hey thanks a ton.. his was so useful…

Custom Search
Copyright 2012 Technically Personal!