Get a domain name


How To Decrease The Load Time Of Your WordPress Blog Using gzip

Sun, Sep 6, 2009

Adding To WordPress

Copy This and Put It Here

Copy

<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], ‘gzip‘)) ob_start(“ob_gzhandler”); else ob_start(); ?>

Paste A (for WordPress users)

For WordPress users, paste the code up at the very top of your header.php file (above the DOCTYPE line). If you’re not sure how to do this, see the video at the end of this tutorial.

gzip-where-to-paste-php

Paste B (for static .html pages)

If your website is coded in html and not php, then what you’ll need to do is copy the code above and paste it up at the very top of each web page you want to compress (above the DOCTYPE).

The one change you’ll need to do here is change the extension of your web pages from .html to .php.

So for example, change: index.html to index.php

You can test your results by visiting http://www.port80software.com.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Related posts:

  1. How To Install Google Analytics On A WordPress Blog Without Using A Plugin
  2. How To Move Your WordPress Core Files Out Of Root
  3. How To Upgrade WordPress Manually
  4. How to Change Your Display Name on Your WordPress Blog

,
John's Wishlist

8 Responses to “How To Decrease The Load Time Of Your WordPress Blog Using gzip”

  1. Keith Davis Says:

    Hi John, very impressive!
    I shall be giving it a go shortly.

    A couple of points that may help your readers who have static html sites…

    First, before you change pages to php, make sure that your hosting service has php on the server you are hosted on. My first site was on a server which was very cheap but didn’t have php.

    Second… use a 301 redirect to direct searches and links for the old html pages to the new php pages. There are lots of articles on the web about how to implement a 301 redirect.

  2. Keith Davis Says:

    Sorry, forgot to add…

    Did I notice Wordpress 2.8.4 in the video?

    Good to see that you are keeping up to date.

  3. John Hoff Says:

    Hi Keith, thanks. Try it out – it works really well. I emailed it to a friend and they tried it out and said they had to change their shorts afterwards LOL.

    Good point about making sure your web hosts uses PHP. If it doesn’t, we certainly offer it. And your comment got me thinking; maybe I’ll do up some .htaccess tutorial videos. I see codes all over online, but no one really shows them in videos, which I’m sure newbies would like since they probably don’t really even know what a .htaccess file is.

    Definitely keep my blogs up to date. Always got to be on top of security, ya know.

  4. Keith Davis Says:

    Hi John
    Started to see posts about Google adding “load time ” as one of the metrics in its algorithm.

    Makes this post even more important!

  5. John Hoff Says:

    That’s interesting. I’ll have to look into that.

  6. Keith Davis Says:

    Hi John
    Came across an article at “Wordpress How To Spotter” that gives details of a tool that checks if your host supports gzip.

    Link to full article is

    http://www.howtospoter.com/web-20/wordpress/3-webmaster-tools-to-improve-blog-performance

    The tool is the first one that is discussed.

    Hope people find it useful

  7. Keith Davis Says:

    Sorry for second comment John.

    Meant to say…. like the new Avatar.
    Shades of sepia?

  8. John Hoff Says:

    Hi Keith. Hey thanks for the tool and the mention about the avatar.

    Yeah I went with sepia tone, why not, right?

    That picture is actually a picture of me holding my 2nd born on his first day in this world. Somehow I didn’t think the picture of a newborn though was what I should put in my avatar. But I think about it every time I see it.

    Also, thanks for the mention on your blog. I appreciate that.


Leave a Reply

PHVsPjxsaT48c3Ryb25nPndvb19hZHNfcm90YXRlPC9zdHJvbmc+IC0gdHJ1ZTwvbGk+PGxpPjxzdHJvbmc+d29vX2FkXzIwMF9hZHNlbnNlPC9zdHJvbmc+IC0gPC9saT48bGk+PHN0cm9uZz53b29fYWRfMjAwX2ltYWdlPC9zdHJvbmc+IC0gPC9saT48bGk+PHN0cm9uZz53b29fYWRfMjAwX3VybDwvc3Ryb25nPiAtIDwvbGk+PGxpPjxzdHJvbmc+d29vX2FkXzMwMF9hZHNlbnNlPC9zdHJvbmc+IC0gPC9saT48bGk+PHN0cm9uZz53b29fYWRfMzAwX2ltYWdlPC9zdHJvbmc+IC0gaHR0cDovL3d3dy53b290aGVtZXMuY29tL2Fkcy93b290aGVtZXMtMzAweDI1MC0yLmdpZjwvbGk+PGxpPjxzdHJvbmc+d29vX2FkXzMwMF91cmw8L3N0cm9uZz4gLSBodHRwOi8vd3d3Lndvb3RoZW1lcy5jb208L2xpPjxsaT48c3Ryb25nPndvb19hZF9jb250ZW50X2Fkc2Vuc2U8L3N0cm9uZz4gLSA8L2xpPjxsaT48c3Ryb25nPndvb19hZF9jb250ZW50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