<?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>Xcellence-IT &#187; Web Development</title>
	<atom:link href="http://www.xcellence-it.com/services/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xcellence-it.com</link>
	<description>Growth Enabling Technology Solutions.</description>
	<lastBuildDate>Fri, 09 Sep 2011 13:49:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>How to Compress HTML / XHTML size to make it load faster</title>
		<link>http://www.xcellence-it.com/tips-tricks/web-development/435/how-to-compress-html-xhtml-size-to-make-it-load-faster/</link>
		<comments>http://www.xcellence-it.com/tips-tricks/web-development/435/how-to-compress-html-xhtml-size-to-make-it-load-faster/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 13:02:52 +0000</pubDate>
		<dc:creator>Xcellence-IT</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.xcellence-it.com/?p=435</guid>
		<description><![CDATA[Compress your html or xhtml code using gzip to optimize the speed of the website.]]></description>
			<content:encoded><![CDATA[<p>Remember earlier we advised you to use <a href="http://www.xcellence-it.com/web-design/simple-inline-form-validation-using-jquery/120" target="_self">three lines code to speed-up your wordpress</a>. That is a nice method to compress html/xhtml code using zlib. Here is the another techniques we employ to compress html code for the server which doesn&#8217;t support zlib compression.</p>
<p>We&#8217;re going to use gzip compression instead of zlib compression.</p>
<p>Here is the one line php code you need to enter into your header file. This will compress html / xhtml code.</p>
<p><span id="more-435"></span></p>
<h3>Here is how it works:</h3>
<p>Well, when the system works normally (I mean without compression), it’s not that efficient. 100KB is a <strong>lot of text</strong>, and frankly, <span>HTML </span>is redundant. Every <code>&lt;html&gt;, &lt;table&gt; and &lt;div&gt;</code> tag has a closing tag that’s almost the same. Words are repeated throughout the document. Any way you slice it, <span>HTML </span>(and its beefy cousin, <span>XML</span>) is not lean.</p>
<p>And what’s the plan when a file’s too big? Zip it!</p>
<p>If we could send a .zip file to the browser (index.html.zip) instead of plain old index.html, we’d save on bandwidth and download time. The browser could download the zipped file, extract it, and then show it to user, who’s in a good mood because the page loaded quickly. The browser-server conversation might look like this:</p>
<ol>
<li>Browser: Hey, can I <strong><span class="caps">GET</span></strong> index.html? I’ll take a compressed version if you’ve got it.</li>
<li>Server: Let me find the file… yep, it’s here. And you’ll take a compressed version? Awesome.</li>
<li>Server: Ok, I’ve found index.html (200 OK), am zipping it and sending it over.</li>
<li>Browser: Great! It’s only 10KB. I’ll unzip it and show the user.</li>
</ol>
<p>The formula is simple: Smaller file = faster download = <strong>happy user</strong>.</p>
<p>Not convinced? Here is the example of yahoo.com, the size of which compressed to around 78% using this technique.</p>
<p>Want to check how much you can save using gzip? Go to <a href="http://www.gidnetwork.com/tools/gzip-test.php" target="_blank">http://www.gidnetwork.com/tools/gzip-test.php</a> and enter your site address to check, how much bandwidth can be saved.</p>
<p>Here we use PHP <a href="http://perishablepress.com/press/2007/03/26/fast-effective-php-compression/"><span class="caps"> </span></a> to return compressed content. Give your <span class="caps">HTML </span>file a .php extension and add this code to the top:</p>
<pre><code>&lt;?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
 ob_start("ob_gzhandler"); else ob_start(); ?&gt;</code></pre>
<h3>Verify Compression:</h3>
<p>Once you’ve configured your server, check to make sure you’re actually serving up compressed content.</p>
<ul>
<li><strong>Online:</strong> Use the <a href="http://www.gidnetwork.com/tools/gzip-test.php">online gzip test</a> to check whether your page is compressed.</li>
<li><strong>In your browser:</strong> Use <a href="https://addons.mozilla.org/en-US/firefox/addon/60">Web Developer Toolbar</a> &gt; Information &gt; View Document Size (like I did for Yahoo, above) to see whether the page is compressed.</li>
<li><strong>View the headers:</strong> Use <a href="https://addons.mozilla.org/en-US/firefox/addon/3829">Live <span>HTTP</span> Headers</a> to examine the response. Look for a line that says “Content-encoding: gzip”.</li>
</ul>
<p>Be prepared to marvel at the results.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcellence-it.com/tips-tricks/web-development/435/how-to-compress-html-xhtml-size-to-make-it-load-faster/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 9/16 queries in 0.005 seconds using disk

Served from: www.xcellence-it.com @ 2012-02-04 22:06:43 -->
