Nullvariable

Enhancing PHP speeds (Drupal and Wordpress too)

by Doug on June 24, 2008

High Speed!Want a quick hack to boost speed of your pages? There are two ways to accomplish this.

  • Login to your server as root or normal with sudo privileges.
    • open your php.ini with vi (command may vary depending on where your php.ini file is located)
    • vi /etc/php.ini

    • Find and uncomment (default is disabled), or add the following line:
    • zlib.output_compression = On

  • This method enhances every site/page using php on the server by sending compressed files to clients that support it.
  • The second method will affect only a single site and requires only access to your .htacess file.
    • open your .htacces file
    • add the following line
    • php_flag zlib.output_compression On

Update: I plan to do some testing on performance to see if this really does help. Just simple visual and file download tests show that it does to me but more data is needed, coming soon!
image credit

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Ping.fm
  • RSS
  • StumbleUpon
  • Twitter
  • Yahoo! Buzz

New here? You may want to subscribe to our RSS feed. You can also find us on Twitter: Doug, Robert

  • Yemek Tarifleri
    Thanks for this. You was help me. Article who your writen was so important for me. Thanks again :) I am reading all articles in happily
  • yes, this technique will compress text files. To my knowledge it doesn't do anything with graphics
  • somchai
    Thank you very much on your comment at DP and point me to this technique, I will try on my site after the host upgrade the php version in next week.
    I never think of "Hallowen color" during design my web theme.

    By the way, all of my contents are html, is it work too?
  • well on my site it seems to make a pretty big difference. I did not actually do any sort of imperical testing. I just tested the difference before and after. Dialup users would see a huge speed boost however since the size of files makes a much bigger difference. According to the benchmarking site that I use, just enabling gzip compression saved a dialup user 6-7 seconds. It reduced the total size of the home page from around 70k to less than 50k (this has changed since that test because I've made several changes to the design since.)
  • This could speed up or slow down your site depending on how your hosting environment is. For example, a box that has high CPU utilization may not benefit as much from this hack, as it takes more horsepower to compress the data before sending it to the client's browser. However, if the network your on is busting at the seams, then this might give you a slight edge.

    Have you done any actual speed tests on your site before and after applying this?

Previous post:

Next post: