Compressing your files to load the pages faster has always been the preference for large files, but depending on your web host, it could be an incredible pain in the neck.
After telling us that it was coming in November of 2009, Google has finally announced as of April that “page load” time is actually a ranking factor now.
For quite a while, (actually since preparing for my Pubcon 2008 hosting presentation), I’ve been looking for a compression option that will work easily, and it turns out that it’s been there right under my nose all along.
Okay, maybe “right under my nose” is an exaggeration, but I was stunned to find out that this is nothing new, and the solution has been around for years. Doh!
On any site hosted on an Apache / PHP web server, all you have to do is paste this code into the top of any page you want compressed, and that’s it… Page compression will be on “automatic”.
<? ob_start(“ob_gzhandler”); ?>
In most WordPress sites, I simply placed it at the top of my header.php file, and saved. A quick check of the site shows it working great.
*** update 5/24/2010 – It seems that when using this for WordPress via header.php, the title tag that gets generated for the site home page by the All-in-One SEO plugin is not working. This stinks, so we’re looking for a fix…
On this particular site, where I’m using the Thesis theme, simply copy/paste into the “Additional Scripts” area in your Thesis site options.
(This does *not* cause a problem for All in One SEO)
On a static .html, .htm, or .php site, just paste it into the shared site-wide header, right at the very top, even before the Doc type statement and other meta data.
It works fine in OC commerce too, after placing it in the top of this file – domain.com/www/includes/application_top.php.
I havent yet tried it on Drupal, Joomla, or Zencart yet because we’ve used other configurations already, but I see no reason it shouldn’t work.
The average data reduction we’re getting is about 70%, but we’ve seen as high as 84%. All in all, this php compression has worked instantly every single place we’ve tried it, other than on a Windows server, where (like so many things Microsoft) it just doesn’t work ;(
Before trying the code, be sure verify whether your site is serving compressed pages . If it’s not, just add the code, and test again to see the automatic change.
Like I said, this php compression solution has been under my nose for a long time, and now it’s under yours too.