<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Geekinator.com &#187; gzip</title>
	<atom:link href="http://www.geekinator.com/tag/gzip/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekinator.com</link>
	<description></description>
	<lastBuildDate>Sat, 10 Jul 2010 16:26:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Speed up your PHP pages with Gzip!</title>
		<link>http://www.geekinator.com/2010/02/06/speed-up-your-php-pages-with-gzip/</link>
		<comments>http://www.geekinator.com/2010/02/06/speed-up-your-php-pages-with-gzip/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 00:51:52 +0000</pubDate>
		<dc:creator>geekinator</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://geekinator.com/?p=13</guid>
		<description><![CDATA[I can&#8217;t believe I haven&#8217;t learned about this little trick until recently, but I&#8217;m sure glad I learned it. A lot of you may already know this, but there&#8217;s a simple little tag you can add to the top of your PHP pages that will speed up the transfer of your site significantly, and on [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t believe I haven&#8217;t learned about this little trick until recently, but I&#8217;m sure glad I learned it. A lot of you may already know this, but there&#8217;s a simple little tag you can add to the top of your PHP pages that will speed up the transfer of your site significantly, and on the fly. Don&#8217;t ask me how it works exactly, but I can tell you that it uses gzip compression (from what I have read) to automatically compress the output of your pages before it&#8217;s sent to the visitors&#8217; browser.</p>
<p>All you have to do is add the following line to the top of any php page you want to compress: ob_start(&#8220;ob_gzhandler&#8221;)</p>
<p>For example, if your page looks like this:</p>
<p>&lt;?php</p>
<p><!--p<--></p>
<p>echo &#8220;This is my page&#8221;;</p>
<p>?&gt;</p>
<p>Your finished, compressed, file would look like:</p>
<p>&lt;?php</p>
<p><!--p<--></p>
<p>ob_start(&#8220;ob_gzhandler&#8221;)</p>
<p>echo &#8220;This is my page&#8221;;</p>
<p>?&gt;</p>
<p>I also read somewhere (and if I can find the post again, I&#8217;ll update this post to give that person credit), that you should add an if statement around that line to make sure the visitor&#8217;s browser supports gzip. I&#8217;m not sure if it&#8217;s absolutely necessary these days, but I added it just to be safe. So, the line I add to my files is:</p>
<p>if(!ob_start(&#8220;ob_gzhandler&#8221;)){ ob_start(); }</p>
<p>Now, I&#8217;m not an expert at compression or anything, but it works and that&#8217;s good enough for me until I find out there&#8217;s some sort of problem with doing it that way. By the way, you can test your page to see if the gzip is actually working or not by going to <a href="http://www.whatsmyip.org/http_compression/" target="_blank">http://www.whatsmyip.org/http_compression/</a>. Another thing I should mention is your server has to have the zlib php library installed and active. You can read more about that at <a href="http://php.net/manual/en/book.zlib.php" target="_blank">http://php.net/manual/en/book.zlib.php</a></p>
<p>On most of my large files, I was able to compress the output by as much as 90% in some cases. The larger your output is, the higher compression you&#8217;ll achieve. I&#8217;m not sure if this is the &#8220;correct&#8221; way of adding the compression to wordpress, but all I did was add the line to the header.php file in my template. I tested the site and it&#8217;s gzipped!</p>
<p>Of course, there&#8217;s also the added bonus (more likely the reason you&#8217;d want to do this for a really large site) of saving on your bandwidth usage. For really large sites, the cost of bandwith can be pretty large, but I think I like the idea of it speeding up the site for my visitors even more than the bandwith savings.</p>
<p>I hope that helped everyone as much as it helped me. Thanks to the guys over at WhatsMyIp.org for the information.</p>
<p><strong>EDIT: </strong>I didn&#8217;t know this until a few days after posting the php code, but you can also gzip an entire site  using .htaccess (at least the html output of the site anyway). All you have to do is add these 2 lines to your .htaccess file:</p>
<p>php_value output_buffering On<br />
php_value output_handler ob_gzhandler</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekinator.com/2010/02/06/speed-up-your-php-pages-with-gzip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
