<?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>The html blog &#187; apache</title>
	<atom:link href="http://htmlblog.net/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://htmlblog.net</link>
	<description>The web sandbox of Asvin Balloo</description>
	<lastBuildDate>Tue, 09 Nov 2010 11:39:27 +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>8 practical tips to make your web pages faster</title>
		<link>http://htmlblog.net/8-practical-tips-to-make-your-web-pages-faster/</link>
		<comments>http://htmlblog.net/8-practical-tips-to-make-your-web-pages-faster/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 16:36:23 +0000</pubDate>
		<dc:creator>asvin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[fast]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[mod_deflate]]></category>
		<category><![CDATA[mod_expires]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[speed up]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://htmlblog.net/?p=40</guid>
		<description><![CDATA[Yahoo&#8217;s Exceptional Performance team has compiled a list of 34 best practices to have faster web pages. In this post I&#8217;ll show you 8 tips which helped me to get a B grade in YSlow! for web pages that I develop. Currently YSlow&#8217;s web page analysis is based on 13 identified basic rules that affect [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm4.static.flickr.com/3062/2520059957_ae331ae75a.jpg?v=0" alt="" /></p>
<div style="clear:both"></div>
<p><a href="http://developer.yahoo.com/performance/rules.html" target="_blank">Yahoo&#8217;s Exceptional Performance team</a> has compiled a list of <a href="http://developer.yahoo.com/performance/rules.html" target="_blank">34 best practices</a> to have faster web pages. In this post I&#8217;ll show you 8 tips which helped me to get a B grade in <a href="http://developer.yahoo.com/yslow/" target="_blank">YSlow!</a> for web pages that I develop. Currently YSlow&#8217;s web page analysis is based on 13 identified basic rules that affect web page performance. In decreasing order of priority they are:</p>
<ol>
<li><a href="http://developer.yahoo.com/performance/rules.html#num_http" target="_blank">Make Fewer HTTP Requests</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#cdn" target="_blank">Use a Content Delivery Network</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#expires" target="_blank">Add an Expires Header</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#gzip" target="_blank">Gzip Components</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#css_top" target="_blank">Put CSS at the Top</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#js_bottom" target="_blank">Move Scripts to the Bottom</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#css_expressions" target="_blank">Avoid CSS Expressions</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#external" target="_blank">Make JavaScript and CSS External</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#dns_lookups" target="_blank">Reduce DNS Lookups</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#minify" target="_blank">Minify JavaScript</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#redirects" target="_blank">Avoid Redirects</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#js_dupes" target="_blank">Remove Duplicate Scripts</a></li>
<li><a href="http://developer.yahoo.com/performance/rules.html#etags" target="_blank">Configure ETags</a></li>
</ol>
<p>You can get more info by clicking on each item. Of course using a <a href="http://en.wikipedia.org/wiki/Content_Delivery_Network" target="_blank">CDN</a> is not affordable by everybody, including me. This didn&#8217;t prevent me to have a B grade though. I will guide you through some of the items which worked for me.<br />
<span id="more-40"></span></p>
<hr/>
<strong>Make Fewer HTTP Requests</strong><br />
If you&#8217;re using the <a href="http://developer.yahoo.com" target="_blank">YUI library</a>, the good news is that recently the team graciously offered a <a href="http://developer.yahoo.com/yui/articles/hosting/" target="_blank">Combo Handler Service</a>, served from their CDN. This helps us to eliminate HTTP requests by requesting a single file. For example, to use the <a href="http://developer.yahoo.com/yui/editor/" target="_blank">Rich Text editor</a>, it needed 6 separate HTTP requests:</p>
<pre lang="html4strict">
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/container/container_core-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/menu/menu-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/element/element-beta-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/button/button-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/editor/editor-beta-min.js"></script>
</pre>
<p>Now with the Combo Handler service, it has been stripped to only 1 file:</p>
<pre lang="html4strict">
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.5.2/build/yahoo-dom-event/yahoo-dom-event.js&#038;2.5.2/build/container/container_core-min.js&#038;2.5.2/build/menu/menu-min.js&#038;2.5.2/build/element/element-beta-min.js&#038;2.5.2/build/button/button-min.js&#038;2.5.2/build/editor/editor-beta-min.js"></script>
</pre>
<p>If you&#8217;re not using the YUI library or not interested in using the Combo Handler service, you can try <a href="http://code.google.com/p/minify/" target="_blank">Minify!</a><br />
<a href="http://code.google.com/p/minify/" target="_blank">Minify</a> is a <a href="http://php.net" target="_blank">PHP5</a> app that can combine multiple CSS or Javascript files, compress their contents (i.e. removal of unnecessary whitespace/comments), and serve the results with HTTP encoding (gzip/deflate) and headers that allow optimal client-side caching.</p>
<p>Another tool which can be helpful is <a href="http://shrinksafe.dojotoolkit.org/" target="_blank">Dojo Shrinksafe</a> which not only minifies your javascript code but also allows you to upload several javascript files and have them compressed in 1 single file.</p>
<p>Another way to make fewer HTTP requests is by using CSS sprites which are big images containing lots of smaller ones. An online tool which can make CSS sprites out of your smaller ones is the <a href="http://spritegen.website-performance.org/" target="_blank">CSS Sprite Generator</a>. You just have to upload your pics and it will generate your sprite together with the CSS code. More info about CSS sprites can be found on <a href="http://css-tricks.com/css-sprites-what-they-are-why-theyre-cool-and-how-to-use-them/" target="_blank">CSS Tricks</a>.</p>
<hr/>
<strong>Add an Expires Header</strong><br />
For this to work on Apache, you&#8217;ll need to have <a href="http://httpd.apache.org/docs/2.0/mod/mod_expires.html" target="_blank">mod_expires</a> enabled. Then create an .htaccess file or edit your httpd.conf with the following content:</p>
<pre lang="apache">
ExpiresActive On
ExpiresByType image/jpg "access plus 2 years"
ExpiresByType image/jpeg "access plus 2 years"
ExpiresByType image/gif "access plus 2 years"
ExpiresByType application/javascript "access plus 2 years"
ExpiresByTYpe text/css "access plus 2 years"
</pre>
<p>In the above listing, all images(jpg/jpeg/gif) will have an expires header 2 years in the future.</p>
<hr/>
<strong>Gzip Components</strong><br />
You must have <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html" target="_blank">mod_deflate</a> enabled and drop these lines in your httpd.conf file</p>
<pre lang="apache">
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
</pre>
<hr/>
<strong>Put CSS at the Top</strong><br />
All CSS must be between your head tag, like that :</p>
<pre lang="html4strict">
	<html>
		<head>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
		</head>
		<body>

		</body>
	</html>
</pre>
<hr/>
<strong>Move Scripts to the Bottom</strong><br />
While the CSS are sitting at the top of your page, javascripts must be moved towards the lower part of your page, typically in the body tag. I usually put them before the closing body tag.</p>
<pre lang="html4strict">
	<html>
		<head>
		</head>
		<body>
		...
		...
		<script type="text/javascript" src="myjs.js"></script>
		</body>
	</html>
</pre>
<hr/>
<strong>Reduce DNS Lookups</strong><br />
I don&#8217;t usually have more than 2 DNS lookups in my scripts, else YSlow will be removing some points.</p>
<hr/>
<strong>Minify JavaScript</strong><br />
As I mentioned earlier on, <a href="http://shrinksafe.dojotoolkit.org/" target="_blank">Dojo Shrinksafe</a> is an online tool which minifies your code.</p>
<p>Another great command line tool is <a href="http://www.julienlecomte.net/blog/2007/08/11/" target="_blank">Julien Lecomte YUI Compressor</a>. </p>
<p>In order to use it you must have <a href="http://java.sun.com" target="_blank">Java</a> installed (>= 1.4).</p>
<p><a href="http://www.crockford.com/" target="_blank">Douglas Crockford</a> also has something similar in <a href="http://www.crockford.com/javascript/jsmin.html" target="_blank">JSMin</a></p>
<hr/>
<strong>Configure ETags</strong><br />
Just drop this line in your httpd.conf:</p>
<pre lang="apache">
FileETag None
</pre>
<p>;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://htmlblog.net/8-practical-tips-to-make-your-web-pages-faster/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>SEO friendly URL in PHP</title>
		<link>http://htmlblog.net/seo-friendly-url-in-php/</link>
		<comments>http://htmlblog.net/seo-friendly-url-in-php/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 18:10:51 +0000</pubDate>
		<dc:creator>asvin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[clean url]]></category>
		<category><![CDATA[french characters]]></category>
		<category><![CDATA[friendly]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[modifier]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[smarty]]></category>
		<category><![CDATA[template engine]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://htmlblog.net/?p=24</guid>
		<description><![CDATA[When I started implementing mod_rewrite in websites I had a problem in PHP as how to make a SEO friendly URL. All tutorials were geared towards how to implement mod_rewrite, about modifying .htaccess files, but none treated how to make the urls friendly with dynamic content. For example I have a news section which are [...]]]></description>
			<content:encoded><![CDATA[<p>When I started implementing <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">mod_rewrite</a> in websites I had a problem in <a href="http://php.net">PHP</a> as how to make a SEO friendly URL. All tutorials were geared towards how to implement mod_rewrite, about modifying .htaccess files, but none treated how to make the urls friendly with dynamic content. For example I have a news section which are pulled from the database, but how can I make the  URL friendly with the title.<br />
<span id="more-24"></span><br />
For example, my problem was to convert titles like &#8220;Barca rejects FIFA statement on Olympics row&#8221; into &#8220;barca-rejects-fifa-statement-on-olympics-row.html&#8221;. The trick has to work also with french titles (I&#8217;am sure my friends at <a href="http://www.nexen.net">Nexen</a> will appreciate ;-)) like &#8220;Guantanamo: le chauffeur de Ben Laden plaide non coupable à l&#8217;ouverture de son procès&#8221; into &#8220;guantanamo-le-chauffeur-de-ben-laden-plaide-non-coupable-a-l-ouverture-de-son-proces.html&#8221;, removing all french accentuated characters.</p>
<p>Hopefully I came across this function which I think might help you too :</p>
<pre class="brush: php">
function friendlyURL($string){
	$string = preg_replace(&quot;`\[.*\]`U&quot;,&quot;&quot;,$string);
	$string = preg_replace(&#039;`&amp;(amp;)?#?[a-z0-9]+;`i&#039;,&#039;-&#039;,$string);
	$string = htmlentities($string, ENT_COMPAT, &#039;utf-8&#039;);
	$string = preg_replace( &quot;`&amp;([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i&quot;,&quot;\\1&quot;, $string );
	$string = preg_replace( array(&quot;`[^a-z0-9]`i&quot;,&quot;`[-]+`&quot;) , &quot;-&quot;, $string);
	return strtolower(trim($string, &#039;-&#039;));
}
</pre>
<p>Use :</p>
<pre class="brush: php">
$myFriendlyURL = friendlyURL(&quot;Barca rejects FIFA statement on Olympics row&quot;);
echo $myFriendlyURL; // will echo barca-rejects-fifa-statement-on-olympics-row
</pre>
<p>You just have to concatenate anything you want with the string afterwards. For french users, make sure your string is encoded in UTF-8 else it won&#8217;t work.</p>
<p>If you&#8217;re using the <a href="http://smarty.php.net">Smarty templating engine</a> I made a little <a href="http://www.smarty.net/manual/en/language.modifiers.php">modifier</a> which you can <a href="http://htmlblog.net/wp-content/uploads/2008/07/modifierfriendlyurl.zip">download</a>. Extract the zip file in your Smarty/libs/plugins/ folder and to use it in your templates :</p>
<pre class="brush: xhtml">
{&quot;Barca rejects FIFA statement on Olympics row&quot; | friendlyURL}
</pre>
<p>Or if your string is in a variable :</p>
<pre class="brush: xhtml">
{$yourString | friendlyURL}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://htmlblog.net/seo-friendly-url-in-php/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
	</channel>
</rss>

