BradBlogging
Skip to content
  • About
  • Contact
  • Advertise
  • What Is R.S.S and Why Subscribe To Us?
  • Free Premium WordPress Themes
Tweet
Share
« BradBlogging’s 2nd Anniversary Makeover With A New Design and Mindset
Bouncing Higher than 80%? Heres 7 Ways To Reduce Your Blog’s Bounce Rate »

Is Your WordPress Slow Loading? Make It 3 Times As Fast In Under A Minute

file-size-zlib-wordpress-compression

With one line of code, you can speed up WordPress to 3x as fast loading than before. By doing this, you give any reader the content you have written at a faster rate, giving them less of a chance to click the back button. This reduces your bounce rate (which I’m going to write about in a future post) and increases visitor interaction and conversion. Why wouldn’t you want this on your blog?

A quick note about the methods used: If you are currently using Gzip, this will not work in conjunction with one another.

UPDATE: [Oct 15th, 2009] – This technique is compatible with WP Super Cache.

zlib Compression for WordPress

zlib Compression in a nutshell takes WordPress code (the php to be exact) and compresses it before sending it to the visitor’s internet browser. The compressed file is then sent to the browser for it to be decompressed and displayed for the user. This process is much faster than just sending the uncompressed data to the browser which uses more bandwidth and is slower to load. The zlib compression will work with all the new major browsers and causes no compatibility problems to the older ones.

Making Sure that zlib Compression is Enabled:

To find out if zlib has been enabled on your web host, simply create a new file in Notepad (Or Notepad++ which is what I use) and paste the following code into the document:

<?php phpinfo(); ?>

Then simply uploading the file to your server and loading it in your browser will show whether you have zlib compression enabled or not. It can be found under a heading called, “zlib”.

Alternatively, if you know that zlib compression is enabled you can skip this step.

The Code:

This code needs to be placed in the header of the document, at the very top of the code – even before the DOCTYPE. (Due to WordPress’s annoying feature that strips the beginning PHP comment out of the post, please type <?php before you paste the code below)

ini_set(‘zlib.output_compression’, ‘On’);
ini_set(‘zlib.output_compression_level’, ’1′);
?>

Then update the header file and you should instantly notice a difference… I know I did!

Check your zlib compression efficiency:

Simply go to http://www.port80software.com/support/p80tools.asp to check your compression factor, percentage and the number of bytes saved.

Conclusion:

I referenced this post for the process and exact code on how to do this, I felt that this would be interesting for anyone with a blog. What inspired me to write this post was WPBlogHost’s post on Gzip compression, although I found out that my web hosting doesn’t support it!

Remember – Too fast is never a bad thing :)

Do you use any plugins or customized code to make WordPress load faster?

This entry was posted in Tutorials and tagged Bandwidth, Data compression, Gzip, Languages, PHP, Programming, Web browser, Wordpress. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Enjoy this post? Theres more to come, so click here to subscribe to our RSS Feed.

Loading...
« BradBlogging’s 2nd Anniversary Makeover With A New Design and Mindset
Bouncing Higher than 80%? Heres 7 Ways To Reduce Your Blog’s Bounce Rate »

51 Comments

  1. Klaus @ TechPatio
    Posted October 15, 2009 at 2:53 am | Permalink

    I was just wondering about two things:

    1) Since PHP is server-side, why send it to the client? I’m not sure that’s what you meant to say? :)

    2) What are the downsides of using this script/method? I’m sure there must be *some* downside, otherwise it would be enabled per default. Or is it only the fact that gzip/wp-cache might not work?

    Reply
    • Brad Ney
      Posted October 15, 2009 at 2:53 pm | Permalink

      Hi Klaus,

      1) It compresses what the PHP outputs (eg – HTML) in WordPress. Perhaps I should of made that more clear :)

      2) There is no downside.. It might just be the fact that some web hosting doesn’t have this enabled, so theme developers skip this little tweak to maximize usability.

      Reply
  2. John - WP Blog Host
    Posted October 15, 2009 at 12:22 pm | Permalink

    Hi Brad, thanks for the link. It’s nice to know you have options when one method won’t work.

    I love tweaking WordPress with these sorts of things. As far as plugins go, I pretty much just use the WP Super Cache to speed things along, it works very well.

    I noticed you had mentioned zlib compression won’t really work if you use the WP Cache plugin, maybe that’s one difference between using gzip and zlib? Right now I’m using gzip to compress my data and WP Super Cache doesn’t seem to mind.

    Reply
    • Brad Ney
      Posted October 15, 2009 at 2:56 pm | Permalink

      Hi John.

      Not a problem – If I didn’t visit your site in the first place, I wouldn’t of known about this tweak :)

      Hmmm.. I just assumed that it wouldn’t work with static HTML files, due to the way that it compresses PHP output. I could be wrong..

      What did you find?

      Reply
  3. Dimitar Nikolov
    Posted October 15, 2009 at 12:23 pm | Permalink

    I hadn’t thought of enabling zlib compression for WordPress, thanks for the informative article!

    What I use on my blog both to speed it up and to reduce traffic is the WP Super Cache plugin. It’s great for when you get a traffic wave from Digg.com, as it caches your WordPress pages and loads a static HTML on every visit, instead of executing long PHP requests.

    Reply
    • Brad Ney
      Posted October 15, 2009 at 3:05 pm | Permalink

      Glad you liked it Dimitar,

      I’m actually going to test the WP Super Cache plugin with this script.. I’ll most likely update it with the results.

      There’s nothing more discouraging then getting a front page article on Digg, then having your server crash under the load.

      Reply
  4. Sanjeev
    Posted October 16, 2009 at 2:28 pm | Permalink

    Hi Brad,Thanks for sharing this information, I tried it on my blog and got the positive result as well. Yes, it is compatible with WP Super Cache and worked fine for me. Bookmarked the page as well.

    Reply
    • Brad Ney
      Posted October 16, 2009 at 7:26 pm | Permalink

      Hi Sanjeev.

      Glad to hear it! When its combined, WP Super Cache and this code make WordPress very fast. :)

      Reply
  5. Frank
    Posted October 23, 2009 at 2:05 pm | Permalink

    Works like a charme!

    Reply
    • Brad Ney
      Posted October 31, 2009 at 8:34 am | Permalink

      Glad to hear it! :)

      Reply
  6. Free Daily Picks
    Posted October 24, 2009 at 1:26 pm | Permalink

    Also if you remove any disabled plugins from your wp-content/plugins folder it speeds it up quite a bit. Every little bit helps. Has anyone else found it runs super slow on Windows?

    Reply
    • Brad Ney
      Posted October 25, 2009 at 6:08 pm | Permalink

      I’m running Windows XP… Think it loads pretty quick.

      Are you sure it isn’t your computer that runs slow, or your web hosting?

      Great tip about the plugins.. didn’t think about that.

      Reply
  7. Free Arcade Games
    Posted October 30, 2009 at 12:55 pm | Permalink

    I’ve used these plugins in the past before on bloggin-ads, but there are always problems. It may be faster for the visitor, but much slower for the owner.

    -Mike
    .-= Free Arcade Games´s last blog ..Hey Wizard =-.

    Reply
    • Brad Ney
      Posted October 31, 2009 at 8:35 am | Permalink

      Hi Mike,

      I don’t think this technique is a plugin, but if your talking about WP-Super Cache, then I’m not sure about your circumstances… It really helps DIGG-Proof my blog!

      Nice to see you here again! :)

      Reply
  8. Antti Kokkonen
    Posted November 2, 2009 at 1:00 am | Permalink

    Have you tested the impact of using compression rules on the .htaccess file (perhaps vs this PHP compression)? I’m interested because unnecessary PHP slow page creation and put load on your host and I like to keep the WP theme as light as possible. Of course one call isn’t that much (especially when highly useful like this one), but if the same can be done on the server level without PHP call, it’s always better…

    Note that WP Super Cache does turn on compression for the HTML files it caches, but compressing CSS, JavaScript, images, etc. needs additional .htaccess rules. If your host supports mod_deflate, that does a great job, but the older mod_gzip is OK too.
    .-= Antti Kokkonen´s last blog ..Analyzing the State of the Blogosphere 2009 =-.

    Reply
    • Brad Ney
      Posted November 2, 2009 at 12:36 pm | Permalink

      I haven’t tried compression through a .htaccess file… would you happen to know how to do that? I’d be glad to write another post based on that if it compresses CSS and Javascript as well. They can get really big, really quickly – especially if you are customizing your template.

      Reply
      • Antti Kokkonen
        Posted November 2, 2009 at 2:07 pm | Permalink

        In short, the mod_deflate compression is used like this (as said, requires that mod_deflate is in use on your host, and not mod_gzip):

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

        I actually written a post couple of weeks ago where I collected the best optimization related htaccess rules, including compression: The Most Essential .htaccess Rules For Blogs

        Reply
        • Brad Ney
          Posted November 2, 2009 at 2:24 pm | Permalink

          WOW – That’s an awesome post! Information overload (in a good way).

          Thanks for the link.. I will be trying many of the techniques out. :)

  9. Gautam
    Posted November 3, 2009 at 8:33 am | Permalink

    Hey thanks for the great article! Got 80% improvement in the loading of the site!
    .-= Gautam´s last blog ..After the Deadline – Spell Checker Plugin for bbPress! =-.

    Reply
    • Brad Ney
      Posted November 3, 2009 at 4:16 pm | Permalink

      You sped up your WordPress loading speed by 80%? That’s incredible! :) I’m really glad you could take advantage of this tutorial!

      Reply
  10. Joseph
    Posted November 13, 2009 at 4:28 pm | Permalink

    Hi Brad,

    I’ve confirmed my host has zlib enabled and added the code to my header.php file as per your instructions but the compression check tells me it’s not enabled!

    Any idea what I might have done wrong?

    Cheers
    Joseph

    Reply
    • Brad Ney
      Posted November 13, 2009 at 5:23 pm | Permalink

      Hi Joseph,

      The tool needs to be refreshed.. IE – Clear your cookies for it to recognize the changes.

      If you’ve already done that, send me an email and I’ll be glad to help you out.

      Thanks!

      Reply
      • Daniel Neubauer
        Posted December 9, 2009 at 4:46 am | Permalink

        Hey Brad,

        very nice post here. Appreciate it.
        I have the same problem that Joseph had.
        I copied the code like you mentioned and then uploaded my new header file.
        But even after deleting my browser cache and after deleting my cookies and reloading the p80tools website to check my status, it tells me that my site status is uncompressed.

        I checked zLip with phpinfo and it tells me it is enabled.

        Do you know what else can be wrong?

        Best regards
        Daniel Neubauer – Webprogrammierer und Front-End-Developer

        Reply
        • Brad Ney
          Posted December 9, 2009 at 6:42 pm | Permalink

          Hey Daniel,

          Glad you enjoyed the post.

          Could you install YSlow and let me know if the result is still the same?

          Perhaps the robots.txt is not allowing the Port80 bot to download your header correctly?

          Feel free to get back to me.

        • Jason
          Posted March 2, 2010 at 10:05 pm | Permalink

          I’m having the same issue as these guys above me…I’ve installed YSlow in Firebug and it too thinks my compression isn’t enabled. I tried both Gzip and Zlib (both of which appear to be enabled in my phpinfo… but Gzip claims it isn’t when I enable it).

          Not sure what to do…this isn’t a HUGE deal for me..but I was excited to implement it and perhaps I will need it in the future. I’m using IXWebhosting…which has be a little weird in the past, so it could just be my host. Anway, let me know if you can help; thanks for the informative article!

  11. gcod
    Posted November 16, 2009 at 8:05 pm | Permalink

    Weird I get an error but my host has zlib:

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /blog/wp-content/themes/tata/header.php on line 13

    Any Idea?

    Reply
    • Brad Ney
      Posted December 9, 2009 at 6:43 pm | Permalink

      Try replacing the quotes with the regular ‘ ones.. I think WordPress formats it with a “beautified” version of a standard code quotation.. That sounds like the problem your facing.

      Reply
  12. Rockstar Sid
    Posted December 12, 2009 at 11:04 pm | Permalink

    Hi Brad,

    Could you look into my website? My VPS host says it is enabled and I have added zlib code on the website but that header checking website still shows ‘uncompressed’..

    Reply
    • Brad Ney
      Posted December 13, 2009 at 4:10 pm | Permalink

      Hey Sid.

      Took a look at your website, it is still uncompressed.

      I’ve fixed the code, I think I know whats causing the problems..

      Could you repaste the code into your header?

      Thanks!

      Reply
      • Rockstar Sid
        Posted January 13, 2010 at 11:28 pm | Permalink

        Hey Brad,

        Really sorry for not getting back to you on time and luckily have bookmarked this website now :) And, I did add the code but it showed uncompressed.. So, later I used this code in htaccess file and it worked for a while :( Don’t know why did it show uncompressed after an hour..

        php_flag zlib.output_compression on
        php_value zlib.output_compression_level 2

        And, the last thing I did was enabling ‘super cache compression’ in wp super cache plugin.. now the files are ‘compressed’ although I don’t know which one is the better.. zlib or super cache compression? :)

        Thanks for the help!
        .-= Rockstar Sid´s last blog ..Another Free Maxim Magazine Subscription For 2010 =-.

        Reply
  13. Sushil
    Posted December 14, 2009 at 12:41 am | Permalink

    Hi Brad

    I m new for wordpress or joomla, I just want to learn how it work on net, first of i want to test on my system, so please tell me how i configure wordpress on local system.

    I m using wampserver on my system, is it possible to work wordpress on wampserver? Please give me some example link, I m expecting for mail

    Thanks

    Reply
  14. Jouke
    Posted December 16, 2009 at 9:42 pm | Permalink

    Having the same problem as Daniel/Joseph/Sid…any update on possible solutions?
    .-= Jouke´s last blog ..Twitter’s New Office =-.

    Reply
    • Brad Ney
      Posted December 17, 2009 at 1:11 pm | Permalink

      Hi Jouke,

      Perhaps you already have it set in the PHP.INI or the .htaccess? If both are set to compress using either Gzip or Zlib (they cannot be used in conjuction) it would result in it being sent uncompressed. Do you have access to those files?

      Thanks.

      Reply
      • Jouke
        Posted December 21, 2009 at 9:13 pm | Permalink

        Brad,

        Its definitely not in my .htaccess file. Couldnt find my php.ini, although a search on google said that shared hosting accounts on Hostgator (which is what i am using) don’t have access to it.
        .-= Jouke´s last blog ..Twitter’s New Office =-.

        Reply
  15. Jayce
    Posted December 19, 2009 at 8:55 am | Permalink

    Having WP Super Cache but did not try the zlib Compression yet. So far less traffic so no issue. ;)
    .-= Jayce´s last blog ..How to hack Facebook account profile =-.

    Reply
  16. Keith Davis
    Posted December 30, 2009 at 5:37 pm | Permalink

    Hi Brad
    Found your site via your comments on John Hoff’s site.
    I was going to implement his gzip compression method but thought better of it when John told me that it may cause problems with IE6 and below.
    Interesting that you have written a post “Are You Missing Out on 14.24% of YOUR Website Conversions?” about IE6.

    You say that “The zlib compression will work with all the new major browsers and causes no compatibility problems to the older ones”
    Does that mean that I can use zlib and not have problems with IE6?
    .-= Keith Davis´s last blog ..The eyes have it! =-.

    Reply
    • Brad Ney
      Posted December 31, 2009 at 6:11 pm | Permalink

      Glad you liked the article Keith!

      I know that IE6 has gzip compression problems, as do the earlier versions of the program. This code will only compress your content if the browser sends the header tags that it “will” accept zlib/gzip compression. I do not believe that IE6 and previous send those tags, so to answer your question, you can use zlib and not affect IE6 users.

      Happy New Year :D

      Reply
      • Jason
        Posted March 2, 2010 at 10:46 pm | Permalink

        I also wanted to point out something I found out about enabling Gzip for IE6 pre- SP2:
        http://www.virtuosimedia.com/tutorials/ultimate-ie6-cheatsheet-how-to-fix-25-internet-explorer-6-bugs#gzip-ie6

        and

        http://sebduggan.com/posts/ie6-gzip-bug-solved-using-isapi-rewrite

        I haven’t yet tried it myself…but it looks promising.

        Reply
        • Brad Ney
          Posted March 5, 2010 at 3:56 pm | Permalink

          Thanks for the find Jason!

          Looks like some good information for those visitors still using IE6.. Oh how I wish they would upgrade. :)

  17. Keith Davis
    Posted December 31, 2009 at 1:50 pm | Permalink

    Thanks Brad
    That’s good news.
    I’ll give it a try and hopefully report back with a super fast blog.

    Happy new year – have a great 2010
    .-= Keith Davis´s last blog ..The eyes have it! =-.

    Reply
  18. Nezine
    Posted December 31, 2009 at 2:04 pm | Permalink

    This is really educational. Thanks, Brad. I will be looking into it.

    For Bloggers Who want to Stop Writers’ Block

    Reply
  19. Keith Davis
    Posted January 1, 2010 at 8:07 am | Permalink

    Hi Brad
    I uploaded the file with “” and got lots, and I mean lots, of info about my hosts PHP setup, but what in particular should I be looking for?

    If I simply add the zlib code to my header and find that it doesn’t work… presumably I can simply remove it without causing any problems.
    .-= Keith Davis´s last blog ..Ooh la la… =-.

    Reply
    • Brad Ney
      Posted January 1, 2010 at 10:56 am | Permalink

      Yeah, the PHPINFO command usually does that.. It displays everything PHP related to you!

      Look for a section with the header “zlib” – In that section it should say “enabled”, if you cannot find it, contact me and I’ll take a look. :)

      Reply
  20. Keith Davis
    Posted January 1, 2010 at 11:48 am | Permalink

    Hi Brad
    Found it and it says… enabled.
    Will add the code to header later and test on the “port80″ software.
    .-= Keith Davis´s last blog ..Ooh la la… =-.

    Reply
  21. Billy
    Posted April 8, 2010 at 7:40 pm | Permalink

    do i put the zlib code in the header.php file? if not, where do i put it?

    Reply
  22. Rodolfo
    Posted April 24, 2010 at 5:49 pm | Permalink

    You must replacing the quotes in the post, like the last in ….pression_level’, ‘1?);
    This is why copy and paste dont work….

    Reply
  23. Richard Baldock
    Posted June 11, 2010 at 2:45 am | Permalink

    Hi Brad, I have tried putting your code in the header.php file above the code already there then my website opens with any content ( blank white screen)

    Please can you confirm the exact file ( there were multiple header.php files) so I chose the one in the theme folder I am running.
    and

    The syntax when the file has other code already in it.

    thanks.

    Reply
    • Brad Ney
      Posted June 12, 2010 at 6:08 pm | Permalink

      Try replacing the quotes – I believe that WordPress replaces the standard quotations with “pretty” ones, nulling the codes effects.

      Reply
  24. Philippe
    Posted July 8, 2010 at 3:46 pm | Permalink

    I LOVE you. The improvement is FANTASTIC. Went from 20 seconds down to 3 seconds of loading of the first page. Thanks, thanks and thanks.

    Reply
  25. How To Unlock PS3
    Posted December 21, 2010 at 10:36 pm | Permalink

    Well, I just found your blog unexpectedly from the search engine. First time I saw it, I know it’s a very informative blog. I got so many something new from here. Good work and thanks for that!

    Reply
  26. Fatima
    Posted March 31, 2011 at 3:58 am | Permalink

    thanks for such a useful post.

    Reply

7 Trackbacks

  1. By Bouncing Higher than 80%? Heres 7 Ways To Reduce Your Blog’s Bounce Rate on October 19, 2009 at 5:02 am

    [...] Brad Blogging Skip to content AboutContact BradAdvertiseWhat Is R.S.S and Why Subscribe To Us? Rss Feed Email Subscriptions Email Me Skype Anyone? « Is Your WordPress Slow Loading? Make It 3 Times As Fast In Under A Minute [...]

  2. By Dramatically Speed Up WordPress/WPMU Load Times With This Simple Tip! | WPMU on December 10, 2009 at 11:40 pm

    [...] first learned about it from Brad Ney in his helpful post. It’s important for you to know that this technique is compatible with WP Super Cache, which [...]

  3. By Eco Friendly Wordpress - and Super Fast on December 18, 2009 at 8:54 am

    [...] http://bradblogging.com/tutorials/speed-wordpress-up-3-times-as-fast-under-a-minute/ [...]

  4. By Dramatically Speed Up WordPress/WPMU Load Times With This Simple Tip! - WordPress MU and BuddyPress plugins, themes, support, tips and how to's on February 22, 2010 at 10:07 am

    [...] first learned about it from Brad Ney in his helpful post. It’s important for you to know that this technique is compatible with WP Super Cache, which [...]

  5. By Acelerar Wordpress x4 | ARS Legal on April 26, 2010 at 12:53 pm

    [...] por la red, me llegue al blog de Brad Ney y como últimamente me preocupa algo el tema de la velocidad de carga de las paginas del blog, ya [...]

  6. By Caching Wordpress - Preparing Your Blog For The Mainstream | BradBlogging on July 20, 2010 at 10:41 am

    [...] things that blog owners can do to speed up their loading times. This doesn’t involve adding header codes to compress the content, rather utilizing a plugin that creates a HTML based document of your dynamic WordPress blog.How To [...]

  7. By Troubleshooting Feed Performance on October 9, 2011 at 11:00 am

    [...] http://bradblogging.com/tutorials/speed-wordpress-up-3-times-as-fast-under-a-minute/ [...]

Post a Comment

Click here to cancel reply.

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badgeShow more posts

2136 RSS Subscribers

Subscribe today to receive any updates on this blog for free!

You'll also receive, "The Blog Manual" free of charge for being a subscriber which you can download at the bottom of each post.

 


Hosted by EZP.net

You might notice how quick this site loads. This is because of EZP.net's awesome web hosting services, from quick support to premium hardware, this company is one notch above the rest. You should use EZP.net to host your sites... They care about their customers.

  • Popular Posts
  • Categories

Popular Articles

  • Optimize Repeated Web Backgrounds with Photoshop
  • 16 Jquery Slideshow Scripts You Cannot Miss
  • How to Create your Own 4 Column Blog Footer - HTML/CSS Included!
  • How To: Reduce Your Blog's Bounce Rate

Blog Categories

  • Advertising & Blogs
  • Article Readability
  • Asides
  • Blog Comments
  • Blog Design
  • Blog Loading Speed
  • Contemplation
  • Featured Posts
  • How To
  • Increase Readers
  • Increase Traffic
  • Interviews
  • Jquery Tools
  • Previous Contests
  • Tutorials
  • Unique Widgets
  • Web Security
  • Website Reviews
  • Wordpress Coding
  • Wordpress Templates

About The Author

Brad Ney

I am a Wordpress enthusiast, part-time website designer, and enjoy using the latest technology via the internet for website promotion. I enjoy writing about startup websites, XHTML, CSS, Wordpress based on what I've learned in the industry.

01. Subscribe!

Click the shiny button for the RSS Feed. This will allow you to recieve each update either via email or via your favourite RSS Reader.
Beats checking the site for new updates!

02. Hand-Picked Articles

  • The Following Mentality Of The Internet
  • Blog Comment Spam
  • Increase Audience Participation with Blog Polls
  • 9 Jquery Slideshow Applications You Cannot Miss

Spend some time reading BradBlogging's most famous blog articles.

03. Start a Blog!

Take advantage of all the information here by using the resources below to start your website:

1. Register A Domain Name

2. Top Notch Web Hosting

04. Contribute

Have a great idea for an article? Want something written about? Drop me a line!

Claim Your Free Blog Guide and Wordpress Template!

It's Brad Here and I just wanted to let you know that you are missing out on two free downloads I have for my readers. You can obtain these downloads for free by subscribing below - I promise that I will not spam and only send you updates from this blog.

Subscribe Today: