<?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>Ardamis &#187; Apache</title>
	<atom:link href="http://www.ardamis.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ardamis.com</link>
	<description>Ardamis is a blog about web development and technology in general.</description>
	<lastBuildDate>Thu, 02 Feb 2012 07:07:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>My new Dell Precision 690 workstation</title>
		<link>http://www.ardamis.com/2011/10/20/my-new-dell-precision-690-workstation/</link>
		<comments>http://www.ardamis.com/2011/10/20/my-new-dell-precision-690-workstation/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 06:06:52 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux-Ubuntu]]></category>
		<category><![CDATA[Materialism]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[XAMPP]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=1737</guid>
		<description><![CDATA[I'm not a hardware guy, but I am excited about what I'm going to do with my new-to-me Dell Precision WorkStation 690.]]></description>
			<content:encoded><![CDATA[<p>I just picked up an old <a href="http://www.dell.com/downloads/global/products/precn/en/spec_precn_690_en.pdf">Dell Precision 690 workstation</a>, which I intend to develop into a file server, a Windows IIS server, and an Ubuntu LAMP server.  This monster was built in 2006, but it still has some neat specs and tons of capacity (7 PCI slots, 4 hard drive bays, etc&#8230;), should I want to expand further.</p>
<h2>The main specs</h2>
<p><strong>CPU:</strong> Dual Core <a href="http://ark.intel.com/products/27211/Intel-Xeon-Processor-5060-(4M-Cache-3_20-GHz-1066-MHz-FSB)">Intel Xeon 5060</a> 3.2GHz, 4M Cache, 1066 MHz FSB<br />
<strong>RAM:</strong> 2GB DDR2 PC2-5300, CL=5, Fully Buffered, ECC, DDR2-667<br />
<strong>HD:</strong> SAS Fujitsu MAX3073RC 73GB, 15000 RPM, 16MB Cache<br />
<strong>Video:</strong> <a href="http://en.wikipedia.org/wiki/Nvidia_Quadro">Nvidia Quadro</a> NVS 285 PCI-Express, 128MB</p>
<h2>This is not a normal tower</h2>
<p>Right away, the size of this thing suggests it isn&#8217;t a normal tower.  It&#8217;s about up to my knee and weights 70 lbs.  It feels like it&#8217;s made with heavier gauge steel than the typical chassis, but that may be me projecting.</p>
<p>I immediately <a href="http://www.ebay.com/sch/i.html?_nkw=dell+workstation+690+memory&#038;_sacat=0&#038;LH_BIN=1&#038;_sop=15&#038;_odkw=dell+workstation+690+memory&#038;_osacat=0&#038;_trksid=p3286.c0.m270.l1313">shopped around for more RAM</a>, obviously.  2GB seems a little thin, even by 2006 standards, when considering the way everything else is high-end.  The mainboard has 8 slots and supports up to 32GB, but I figure 6GB is a safe place to start.</p>
<p>The workstation has three enormous fans, like, big-as-your-hand big.  Running it with the chassis open causes some sort of thermal protection system to kick in and it spins the fans up to the point that they were blowing stuff on the floor half-way across the room.</p>
<p>The CPU has a big, passive heat sink with six copper pipes and sits between two of those fans.  I&#8217;m tempted to buy a second CPU, but I&#8217;ll hold off.</p>
<p>I&#8217;m still on the fence about the SCSI drive.  It should be super fast, but I&#8217;m a little spoiled by the SSD in my machine at work, so it&#8217;s hard to get excited about a mechanical drive, even one running at 15k RPM.</p>
<p>The Nvidia Quadro card is also fanless, and has a bizarre <a href="http://en.wikipedia.org/wiki/DMS-59">DMS-59</a> connector.  An adapter converts the DMS-59 connector into two DVI outputs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2011/10/20/my-new-dell-precision-690-workstation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jealous of The Social Network</title>
		<link>http://www.ardamis.com/2011/06/12/jealous-of-the-social-network/</link>
		<comments>http://www.ardamis.com/2011/06/12/jealous-of-the-social-network/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 02:46:50 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Nonsense]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web app]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=1467</guid>
		<description><![CDATA[A short list of my programming accomplishments.]]></description>
			<content:encoded><![CDATA[<p>So I finally watched <a href="http://en.wikipedia.org/wiki/The_Social_Network"><em>The Social Network</em></a> over the weekend, and it&#8217;s made me feel jealous and a bit guilty.</p>
<p>In a meager effort to console myself for so far failing to be a billionaire, I&#8217;m assembling the short list of web-application type things I&#8217;ve built here.</p>
<ol>
<li>A dice roller: <a href="http://alephstudios.com/rollforit/">rollforit</a>. Enter a name, create a room, invite your friends, and start rolling dice.  For people who want to play pen and paper, table-top RPG dice games with their distant friends.</li>
<li>A URL shortener: <a href="http://minifi.de/">Minifi.de</a>.  Minifi.de comes with an API and a bookmarklet.  It really works, too!  The <a href="http://minifi.de/technical.php">technical explanation</a> has more details.</li>
<li>A social networking site: <a href="http://alephstudios.com/snapbase/">Snapbase</a>.  Snapbase is a social site that shows you what&#8217;s going on in your city or anywhere in the world as pictures are uploaded by your friends and neighbors.  The application extracts location information from the EXIF data embedded in images and displays recent images taken near your present location.</li>
<li>A <a href="http://alephstudios.com/helpdesk/">trouble-ticketing system</a> for an IT help desk or technical support center.  It&#8217;s really pretty extensive, with asset management, user accounts, salted encrypted passwords, and all sorts of nifty things.  I really must write a full description of it at some point, but until then, the <a href="http://alephstudios.com/helpdesk/documentation/">documentation</a> is the next best thing.</li>
<li>An <a href="http://alephstudios.com/ias/">account-based invoice tracking and access system</a> for grouping invoices according to clients, then sharing invoice history with those clients and allowing them to easily pay outstanding invoices via Paypal.</li>
<li>An <a href="http://alephstudios.com/ias/">account-based invoice access system</a> where clients can view paid and unpaid invoices, and even easily pay an outstanding invoice via Paypal. I actually use this almost every day.</li>
<li>A simple method for <a href="http://www.ardamis.com/2008/06/11/protecting-a-download-using-a-unique-url/">protecting a download using a unique URL</a> that can be emailed to authorized users. The URL can be set to expire after a certain amount of time or any number of downloads.</li>
<li>An update to the above download protection script to <a href="http://www.ardamis.com/2009/06/26/protecting-multiple-downloads-using-unique-urls/">protect multiple downloads</a>, generate batches of keys, leave notes about who received the key, the ability to specify per-key the allowable number of downloads and age, and some basic reporting.</li>
<li>An HTML auction template generator called <a href="http://simpleauctionwizard.com/">Simple Auction Wizard</a>.  It helps you create HTML auction templates for eBay, and uses SWFUpload and tinyMCE.</li>
</ol>
<p>I have another project in the works that promises to be more financially viable, but the most clever thing on that list is Snapbase.  It&#8217;s in something akin to alpha right now; barely usable.  I really wish I had the time to pursue it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2011/06/12/jealous-of-the-social-network/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix the &#8220;PHP Fatal error:  Call to undefined function  get_header()&#8221; error in WordPress</title>
		<link>http://www.ardamis.com/2011/06/02/fix-for-php-fatal-error-get_header-in-wordpress/</link>
		<comments>http://www.ardamis.com/2011/06/02/fix-for-php-fatal-error-get_header-in-wordpress/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 17:07:13 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[500 error]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=1430</guid>
		<description><![CDATA[Fix the "PHP Fatal error: Call to undefined function get_header()" error in WordPress.]]></description>
			<content:encoded><![CDATA[<p>While making changes to my WordPress theme, I noticed that the error_log file in my theme folder contained dozens of PHP Fatal error lines:</p>
<pre class="brush: plain; title: ; notranslate">
...
[01-Jun-2011 14:25:15] PHP Fatal error:  Call to undefined function  get_header() in /home/accountname/public_html/ardamis.com/wp-content/themes/ars/index.php on line 7
[01-Jun-2011 20:58:23] PHP Fatal error:  Call to undefined function  get_header() in /home/accountname/public_html/ardamis.com/wp-content/themes/ars/index.php on line 7
...
</pre>
<p>The first seven lines of my theme&#8217;s index.php file:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php ini_set('display_errors', 0); ?&gt;
&lt;?php
/**
 * @package WordPress
 * @subpackage Ars_Theme
*/
get_header(); ?&gt;
</pre>
<p>I realized that the error was being generated each time that my theme&#8217;s index.php file was called directly, and that the error was caused by the theme&#8217;s inability to locate the WordPress <strong>get_header</strong> function (which is completely normal).  Thankfully, the descriptive error wasn&#8217;t being output to the browser, but was only being logged to the error_log file, due to the inclusion of the <strong>ini_set(&#8216;display_errors&#8217;, 0);</strong> line.  I had learned this the hard way a few months ago when I found that calling the theme&#8217;s index.php file directly would generate an error message, output to the browser, that would reveal my hosting account username as part of the absolute path to the file throwing the error.</p>
<p>I decided the best way to handle this would be to check to see if the file could find the <strong>get_header</strong> function, and if it could not, simply redirect the visitor to the site&#8217;s home page.  The code I used to do this:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php ini_set('display_errors', 0); ?&gt;
&lt;?php
/**
* @package WordPress
* @subpackage Ars_Theme
*/
if (function_exists('get_header')) {
	get_header();
}else{
    /* Redirect browser */
    header(&quot;Location: http://&quot; . $_SERVER['HTTP_HOST'] . &quot;&quot;);
    /* Make sure that code below does not get executed when we redirect. */
    exit;
}; ?&gt;
</pre>
<p>So there you have it.  No more fatal errors due to <strong>get_header</strong> when loading the WordPress theme&#8217;s index.php file directly.  And if something else in the file should throw an error, <strong>ini_set(&#8216;display_errors&#8217;, 0);</strong> means it still won&#8217;t be sent to the browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2011/06/02/fix-for-php-fatal-error-get_header-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Online tools for detecting malware on web sites</title>
		<link>http://www.ardamis.com/2011/05/07/detecting-malware-on-web-sites/</link>
		<comments>http://www.ardamis.com/2011/05/07/detecting-malware-on-web-sites/#comments</comments>
		<pubDate>Sat, 07 May 2011 18:48:22 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Nonsense]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=1275</guid>
		<description><![CDATA[Online tools for detecting infections on web sites and for identifying vulnerabilites.]]></description>
			<content:encoded><![CDATA[<p>Just a few notes to myself about monitoring web sites for infections/malware and potential vulnerabilities.</p>
<h2>Tools for detecting infections on web sites</h2>
<h3>Google Webmaster Tools</h3>
<p>Your first stop should be here, as I&#8217;ve personally witnessed alerts show up in Webmaster Tools, even when all the following tools gave the site a passing grade.  If your site is registered here, and Google finds weird pages on your site, an alert will appear.  You can also have the messages forwarded to your email account on file, by choosing the Forward option under the All Messages area of the Home page.</p>
<div id="attachment_1382" class="wp-caption aligncenter" style="width: 784px"><a href="http://www.ardamis.com/wp-content/uploads/2011/05/google-webmaster-tools-hack-alert.png"><img src="http://www.ardamis.com/wp-content/uploads/2011/05/google-webmaster-tools-hack-alert.png" alt="" title="google-webmaster-tools-hack-alert" width="774" height="435" class="size-full wp-image-1382" /></a><p class="wp-caption-text">Google Webmaster Tools Hack Alert</p></div>
<h3>Google Safe Browsing</h3>
<p>The Google Safe Browsing report for ardamis.com: <a href="http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=ardamis.com">http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=ardamis.com</a></p>
<h3>Norton Safe Web</h3>
<p><a href="https://safeweb.norton.com/">https://safeweb.norton.com/</a></p>
<p>The Norton Safe Web report for ardamis.com: <a href="https://safeweb.norton.com/report/show?url=ardamis.com">https://safeweb.norton.com/report/show?url=ardamis.com</a></p>
<h2>Tools for analyzing a site for vulnerabilities</h2>
<h3>Sucuri Site Check</h3>
<p><a href="http://sitecheck.sucuri.net/scanner/">http://sitecheck.sucuri.net/scanner/</a></p>
<p>The Sucuri report for ardamis.com: <a href="http://sitecheck.sucuri.net/scanner/?scan=www.ardamis.com">http://sitecheck.sucuri.net/scanner/?scan=www.ardamis.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2011/05/07/detecting-malware-on-web-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W3C Link Checker fails with an Error: 406 Not Acceptable</title>
		<link>http://www.ardamis.com/2011/04/08/w3c-link-checker-fails-with-an-error-406-not-acceptable/</link>
		<comments>http://www.ardamis.com/2011/04/08/w3c-link-checker-fails-with-an-error-406-not-acceptable/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 18:50:06 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Nonsense]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=1192</guid>
		<description><![CDATA[Attempting to run the W3C Link Checker against http://www.ardamis.com/ returns a 406 error message.]]></description>
			<content:encoded><![CDATA[<p>Attempting to run the <a href="http://validator.w3.org/checklink">W3C Link Checker</a> against http://www.ardamis.com/ returns an error message.</p>
<blockquote><p>Error: 406 Not Acceptable</p></blockquote>
<p>This is what the W3C says about the 406 HTTP status header:</p>
<blockquote><p><strong>406 Not Acceptable</strong><br />The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.<br />
<br /><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html</a></p></blockquote>
<p>In other words, the W3C Link Checker requests the web page, and tells the web server that, by the way, it can only accept a responses in a certain format.  The web server then regrets to inform the requestor that it cannot fulfill this request, because it cannot return a response that would be acceptable to the requestor.  It does this in the form of a 406 Not Acceptable HTTP header.  The W3C Link Checker then outputs this error.</p>
<p>Other W3C apps, like <a href="http://validator.w3.org/unicorn/">Unicorn &#8211; W3C&#8217;s Unified Validator</a> and the <a href="http://validator.w3.org/">W3C HTML Validator</a> don&#8217;t seem to be sending the same HTTP headers.  (But I did note that there were a few small issues preventing the home page from passing the test, which I then fixed.) </p>
<p>Ardamis runs on WordPress, with a custom theme originally developed years ago from the Kubrick theme and a handful of plugins (as more completely described at the <a href="http://www.ardamis.com/colophon/">colophon</a> page).  I tinker with the site, from time to time, trying to speed it up or what-have-you.  But no amount of tinkering seemed to resolve this problem.  Over the course of a few months, I&#8217;d try various changes to the site to see if there was something I could do to fix this problem.  I had pretty much convinced myself that it was going to be an issue for my web host when, miraculously, after making some changes to the .htaccess file, my theme and disabling one of the plugins (which I can&#8217;t see how would possibly affect the HTTP headers) the Link Checker began working.</p>
<p>In the <a href="http://validator.w3.org/checklink?uri=http%3A%2F%2Fwww.ardamis.com%2F&#038;hide_type=all&#038;depth=&#038;check=Check">results page for www.ardamis.com</a>, it lists some of the headers used:</p>
<blockquote><p>Settings used:</p>
<ul>
<li><tt><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">Accept</a></tt>: text/html, application/xhtml+xml;q=0.9, application/vnd.wap.xhtml+xml;q=0.6, */*;q=0.5</li>
<li><tt><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4">Accept-Language</a></tt>: en-US,en;q=0.8</li>
<li><tt><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.36">Referer</a></tt>: sending</li>
<li>Sleeping 1 second between requests to each server</li>
</ul>
</blockquote>
<p>I&#8217;m not sure what I did to make this work, or even if it was something I did.  But further troubleshooting would have involved disabling all plugins, trying a different theme, and then ruling out WordPress entirely.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2011/04/08/w3c-link-checker-fails-with-an-error-406-not-acceptable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A chart illustrating the reduction in comment spam at ardamis.com</title>
		<link>http://www.ardamis.com/2011/01/18/a-chart-illustrating-the-reduction-in-comment-spam-at-ardamis-com/</link>
		<comments>http://www.ardamis.com/2011/01/18/a-chart-illustrating-the-reduction-in-comment-spam-at-ardamis-com/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 19:12:09 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[500 error]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[comment spam]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=1228</guid>
		<description><![CDATA[A screenshot of the Akismet stats graph showing the number of spam comments at ardamis.com identified by Akismet before and after my anti-spam system was implemented.]]></description>
			<content:encoded><![CDATA[<p>In August, 2010, I described <a href="http://www.ardamis.com/2010/08/09/reducing-wordpress-spam-comments/">a simple method for dramatically reducing the number of spam comments</a> that are submitted to a WordPress blog.  The spam comments are rejected before they are checked by Akismet, so they never make it into the database at all.</p>
<p>Now, a few months later, I&#8217;m posting a screenshot of the Akismet stats graph from the WordPress dashboard showing the number of spam comments identified by Akismet before and after the system was implemented.</p>
<div id="attachment_1229" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.ardamis.com/wp-content/uploads/2011/01/akismet-500.jpg"><img src="http://www.ardamis.com/wp-content/uploads/2011/01/akismet-500.jpg" alt="" title="akismet-500" width="500" height="340" class="size-full wp-image-1229" /></a><p class="wp-caption-text">Akismet stats for August - December, 2010</p></div>
<p>The spike in spam comments detected around November 3rd occurred after an update to WordPress overwrote my altered wp-comments.php file.  I replaced the file and the spam dropped back down to single digits per day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2011/01/18/a-chart-illustrating-the-reduction-in-comment-spam-at-ardamis-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to speed up WordPress</title>
		<link>http://www.ardamis.com/2010/08/03/how-to-speed-up-wordpress/</link>
		<comments>http://www.ardamis.com/2010/08/03/how-to-speed-up-wordpress/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 05:35:14 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=811</guid>
		<description><![CDATA[How to speed up WordPress by reducing HTTP requests and database look ups, using a faster mod_rewrite code, and shrinking the size of the database.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written a few posts on how to speed up web sites by <a href="http://www.ardamis.com/2010/07/17/sending-headers-to-leverage-browser-caching/">sending the correct headers to leverage browser caching</a> and <a href="http://www.ardamis.com/2010/07/11/compress-files-without-mod_gzip-or-mod_deflate/">compressing .php, .css and .js files without mod_gzip or mod_deflate</a>.</p>
<p>The intended audience for this post is developers who have already applied most or all of Google&#8217;s <a href="http://code.google.com/speed/page-speed/docs/rules_intro.html">Web Performance Best Practices</a> and Yahoo&#8217;s <a href="http://developer.yahoo.com/performance/rules.html">Best Practices for Speeding Up Your Web Site</a> and are wondering how to speed up WordPress sites in particular.</p>
<p>I assume you&#8217;re familiar with <a href="http://codex.wordpress.org/WordPress_Optimization/Caching">WordPress caching</a> and are already using a caching plugin, such as <a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache</a>, <a href="http://wordpress.org/extend/plugins/w3-total-cache/">W3 Total Cache</a> or the like.  </p>
<h2>Reduce HTTP requests</h2>
<p>Reducing HTTP requests should be the very first thing step in speeding up any site.  If you are using plugins, watch them carefully for inefficiencies like added CSS and JavaScript files.  Combine, minify and compress these files.  Some plugins allow you to turn off their bundled CSS in the plugin&#8217;s settings page.  Where possible, copy the plugin&#8217;s CSS into the current theme&#8217;s style.css and turn off the extra file.</p>
<h2>Delete deactivated plugins</h2>
<p>Remove any plugins you&#8217;re not using.  Deactivated plugins can be deleted from the Plugins page.</p>
<h2>Speed up the mod_rewrite code</h2>
<p><a href="http://www.webmasterworld.com/profilev4.cgi?action=view&#038;member=jdMorgan">jdMorgan</a> from WebmasterWorld.com has written a replacement for the .htaccess rewrite rule used by WordPress.  This will speed up the WordPress mod_rewrite code by a factor of more than two.</p>
<blockquote><p>This is a total replacement for the code supplied with WP as bounded by the &#8220;Begin WP&#8221; and &#8220;End WP&#8221; comments, and fixes several performance-affecting problems. Notably, the unnecessary and potentially-problematic <IfModule> container is completely removed, and code is added and re-structured to both prevent completely-unnecessary file- and directory- exists checks and to reduce the number of necessary -exists checks to one-half the original count (due to the way mod_rewrite behaves recursively in .htaccess context).</p>
<p><a href="http://www.webmasterworld.com/apache/4053973.htm">http://www.webmasterworld.com/apache/4053973.htm</a>
</p></blockquote>
<p>The following code is adapted from the original to add png, flv and swf to the list of static file formats:</p>
<pre class="brush: plain; title: ; notranslate">
# BEGIN WordPress
# adapted from http://www.webmasterworld.com/apache/4053973.htm
#
RewriteEngine on
#
# Unless you have set a different RewriteBase preceding this point,
# you may delete or comment-out the following RewriteBase directive
# RewriteBase /
#
# if this request is for &quot;/&quot; or has already been rewritten to WP
RewriteCond $1 ^(index\.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 \.(gif|jpg|png|ico|css|js|flv|swf)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule . /index.php [L]
#
# END wordpress
</pre>
<h2>Only load the comment-reply.js when needed</h2>
<p>In the default WordPress template, the <strong>comment-reply.js</strong> script is included on all single post pages, regardless of whether nested/threaded comments is enabled.  A simple tweak changes the theme to only include <strong>comment-reply.js</strong> on single post pages only when it makes sense to do so: if threaded comments are enabled, commenting on that post is allowed, and a comment already exists.</p>
<p>Remove the following line from your theme&#8217;s <strong>header.php</strong>:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?&gt;
</pre>
<p>Add the following lines to your theme&#8217;s <strong>functions.php</strong>.</p>
<pre class="brush: php; title: ; notranslate">
// Don't add the wp-includes/js/comment-reply.js?ver=20090102 script to single post pages unless threaded comments are enabled
// adapted from http://bigredtin.com/behind-the-websites/including-wordpress-comment-reply-js/
function theme_queue_js(){
  if (!is_admin()){
    if (is_singular() &amp;&amp; (get_option('thread_comments') == 1) &amp;&amp; comments_open() &amp;&amp; have_comments())
      wp_enqueue_script('comment-reply');
  }
}
add_action('wp_print_scripts', 'theme_queue_js');
</pre>
<h2>Only load the l10n.js when needed</h2>
<p>In WordPress 3.1, a <strong>l10n.js</strong> script is loaded.  It is &#8220;mostly used for scripts that send over localization data from PHP to the JS side using <em>wp_localize_script()</em>.&#8221; Whether it&#8217;s safe to remove this file seems to be a matter of debate, but should you decide you want to remove it&#8230;</p>
<p>Add the following lines to your theme&#8217;s <strong>functions.php</strong>.</p>
<pre class="brush: php; title: ; notranslate">
// Don't add the wp-includes/js/l10n.js?ver=20101110 script to non-admin pages
// adapted from http://wordpress.stackexchange.com/questions/5451/what-does-l10n-js-do-in-wordpress-3-1-and-how-do-i-remove-it
function remove_l10n_js(){
  if (!is_admin()){
    wp_deregister_script('l10n');
  }
}
add_action('wp_print_scripts', 'remove_l10n_js');
</pre>
<h2>Replace unecessary code executions and database queries</h2>
<p>WordPress saves settings specific to your blog in the database.  These settings include what language your blog is written in, whether text is read left-to-right or vice versa, the path to the template directory, etc.</p>
<p>The default WordPress theme contains a number of database queries in order to figure out these things and build the correct page.  The default theme needs this flexibility, but your theme does not.  Joost de Valk recommends replacing these database queries with static text in your theme files in his post <a href="http://yoast.com/speed-up-wordpress/">Speed up WordPress, and clean it up too!</a></p>
<p>An easy way to do this is to browse to your web site and then view the source code.  Copy the content that won&#8217;t change from page to page and paste it into your theme, overwriting the PHP with the generated HTML.</p>
<p>For example, my theme&#8217;s header.php file contains this line:</p>
<pre class="brush: php; title: ; notranslate">
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &lt;?php language_attributes(); ?&gt;&gt;
</pre>
<p>The source code of the rendered page displays this line:</p>
<pre class="brush: php; title: ; notranslate">
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; dir=&quot;ltr&quot; lang=&quot;en-US&quot;&gt;
</pre>
<p>On my blog, this HTML output is never going to be anything different, so why make WordPress look these settings up in the database each time a page is loaded?  This line is an excellent candidate for replacement.  The footer.php file contains a handful more opportunities for replacement, but go through each of your theme&#8217;s files and look for references to the template directory and other data that won&#8217;t change as long as you&#8217;re using the theme.  All told, I was able to replace 12 database queries with static HTML.</p>
<p>Joost also recommends checking for unnecessary or slow database queries, and installing a helpful debugging plugin, in his post on <a href="http://yoast.com/wordpress-performance-optimization/">Optimizing WordPress database performance</a>.</p>
<h2>Clean out your MySQL database</h2>
<h3>Delete spam comments</h3>
<p>From the Dashboard, click Comments, then click on Empty Spam.</p>
<h3>Delete post revisions</h3>
<p>If you don&#8217;t use post revisions, you may want to delete them from the <code>wp_posts</code> table.  Back up your database, then run the following SQL query:</p>
<pre class="brush: sql; title: ; notranslate">
DELETE FROM wp_posts WHERE post_type = &quot;revision&quot;;
</pre>
<p>Before: 683 records<br />
After: 165 records</p>
<p>This does not delete the latest draft of unpublished posts.  It&#8217;s a good idea to optimize the table after deleting the revisions.</p>
<p>You can stop WordPress from saving post revisions by adding the following code to wp-config.php:</p>
<pre class="brush: php; title: ; notranslate">
define('WP_POST_REVISIONS', false );
</pre>
<h2>Optimize your MySQL database</h2>
<p>Optimizing your MyISAM tables is comparable to defragmenting your hard drive.  It&#8217;s probably been a while since you&#8217;ve done that, too.</p>
<p>If you&#8217;re using phpMyAdmin, browse to your WordPress database.  Under the Structure tab, at the bottom of the list of tables, click on the link &#8220;Check all&#8221;.  In the &#8220;With selected&#8221; menu, choose &#8220;Optimize table&#8221;.  (I would have recommended just optimizing tables that have overhead, but the <code>wp_posts</code> table can be optimized even when it doesn&#8217;t show any overhead.</p>
<blockquote><p>For MyISAM tables, OPTIMIZE TABLE works as follows:</p>
<ul>
<li>If the table has deleted or split rows, repair the table.</li>
<li>If the index pages are not sorted, sort them.</li>
<li>If the table&#8217;s statistics are not up to date (and the repair could not be accomplished by sorting the index), update them.</li>
</ul>
<p><a href="http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html">http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html</a></p></blockquote>
<h2>Flush the Buffer Early</h2>
<blockquote><p>When users request a page, it can take anywhere from 200 to 500ms for the backend server to stitch together the HTML page. During this time, the browser is idle as it waits for the data to arrive. In PHP you have the function <code><a href="http://php.net/flush">flush()</a></code>. It allows you to send your partially ready HTML response to the browser so that the browser can start fetching components while your backend is busy with the rest of the HTML page. The benefit is mainly seen on busy backends or light frontends.</p>
<p><a href="http://developer.yahoo.com/performance/rules.html#flush">http://developer.yahoo.com/performance/rules.html#flush</a></p></blockquote>
<p>Add <code>flush()</code> between the closing <code></head></code> tag and the opening <code><body></code> tag in <strong>header.php</strong>.</p>
<pre class="brush: php; title: ; notranslate">
&lt;/head&gt;
&lt;?php flush(); // http://developer.yahoo.com/performance/rules.html#flush ?&gt;
&lt;body&gt;
</pre>
<p>OK, so this isn&#8217;t technically a WordPress-specific tweak, but it&#8217;s a good idea.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2010/08/03/how-to-speed-up-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to send the correct headers to leverage browser caching</title>
		<link>http://www.ardamis.com/2010/07/17/sending-headers-to-leverage-browser-caching/</link>
		<comments>http://www.ardamis.com/2010/07/17/sending-headers-to-leverage-browser-caching/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 23:23:39 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[godaddy]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=794</guid>
		<description><![CDATA[How to use .htaccess to send the correct HTTP headers in order to leverage browser caching and reduce page load times for returning visitors.]]></description>
			<content:encoded><![CDATA[<p>As a follow-up to my post on <a href="http://www.ardamis.com/2010/07/11/compress-files-without-mod_gzip-or-mod_deflate/">compressing .php, .css and .js files without mod_gzip or mod_deflate</a>, I&#8217;m documenting the changes I made to the .htaccess file on ardamis.com in order to speed up page load times for returning visitors and satisfy the <a href="http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching">Leverage browser caching</a> recommendation of Google&#8217;s <a href="http://code.google.com/speed/page-speed/">Page Speed</a> Firefox/Firebug Add-on. </p>
<p>A great explanation of why browser caching helps the web deliver a better user experience is at <a href="http://betterexplained.com/articles/how-to-optimize-your-site-with-http-caching/">betterexplained.com</a>.</p>
<p>Two authoritative articles on the subject are Google&#8217;s <a href="http://code.google.com/speed/page-speed/docs/caching.html">Performance Best Practices | Optimize caching</a> and Yahoo&#8217;s <a href="http://developer.yahoo.com/performance/rules.html#expires">Best Practices for Speeding Up Your Web Site | Add an Expires or a Cache-Control Header</a>.</p>
<p>I&#8217;d like to point out that in researching browser cashing, I came across a lot of information that contradicted the rather clear instructions from Google:</p>
<blockquote><p>It is important to specify one of <code>Expires</code> or <code>Cache-Control max-age</code>, <i>and</i> one of <code>Last-Modified</code> or <code>ETag</code>, for all cacheable resources. It is redundant to specify both <code>Expires</code> and <code>Cache-Control: max-age</code>, or to specify both <code>Last-Modified</code> and <code>ETag</code>.</p></blockquote>
<p>I&#8217;m not sure that this recommendation is entirely correct, as the W3C states that Expires and Cache-Control max-age are used in different situations, with Cache-Control max-age overriding Expires in the event of conflicts.</p>
<blockquote><p>If a response includes both an Expires header and a max-age directive, the max-age directive overrides the Expires header, even if the Expires header is more restrictive. This rule allows an origin server to provide, for a given response, a longer expiration time to an HTTP/1.1 (or later) cache than to an HTTP/1.0 cache.</p>
<p><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a></p></blockquote>
<p>It would seem that Cache-Control is the preferred method of controlling browser caching going forward.</p>
<blockquote><p>HTTP 1.1 clients will honour &#8220;Cache-Control&#8221; (which is easier to use and much more flexible).<br />
HTTP 1.0 clients will ignore &#8220;Cache-Control&#8221; but honour &#8220;Expires&#8221;. With &#8220;Expires&#8221; you get thus at least a bit control for these old clients.</p>
<p><a href="http://www.peterbe.com/plog/cache-control_or_expires">http://www.peterbe.com/plog/cache-control_or_expires</a></p></blockquote>
<p>In any event, Page Speed won&#8217;t protest if you do end up sending both Expires and Cache-Control max-age, or if you remove both Last-Modified and ETag, but I was able to get the best results with just setting Cache-Control max-age and removing the ETag.</p>
<h2>Setting the headers in .htaccess</h2>
<p>On Apache, configuring the proper headers can be done in the .htaccess file, using the <code>Header</code> directive.  The <code>Header</code> directive requires the <code>mod_headers</code> module to be enabled.</p>
<p>I&#8217;m choosing to set a far future Expires header of one year on my images files, because I tweak the CSS and JavaScript pretty often, and don&#8217;t want those file types to be cached as long.</p>
<p>Add the following code to your .htaccess file to set your Cache-Control and Expires headers, adjusting the date to be one year from today.</p>
<pre class="brush: plain; title: ; notranslate">
# Set Cache-Control and Expires headers
&lt;filesMatch &quot;\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$&quot;&gt;
Header set Cache-Control &quot;max-age=2592000, private&quot;
Header set Expires &quot;Sun, 17 July 2011 20:00:00 GMT&quot;
&lt;/filesMatch&gt;
&lt;filesMatch &quot;\\.(css|css.gz)$&quot;&gt;
Header set Cache-Control &quot;max-age=604800, private&quot;
&lt;/filesMatch&gt;
&lt;filesMatch &quot;\\.(js|js.gz)$&quot;&gt;
Header set Cache-Control &quot;max-age=604800, private&quot;
&lt;/filesMatch&gt;
&lt;filesMatch &quot;\\.(xml|txt)$&quot;&gt;
Header set Cache-Control &quot;max-age=216000, private, must-revalidate&quot;
&lt;/filesMatch&gt;
&lt;filesMatch &quot;\\.(html|htm)$&quot;&gt;
Header set Cache-Control &quot;max-age=7200, private, must-revalidate&quot;
&lt;/filesMatch&gt;
</pre>
<h2>Removing ETags in .htaccess</h2>
<p>Most sources recommend simply removing ETags if they are not required.</p>
<blockquote><p>Entity tags (ETags) are a mechanism that web servers and browsers use to determine whether the component in the browser&#8217;s cache matches the one on the origin server.<br />
&#8230;<br />
If you&#8217;re not taking advantage of the flexible validation model that ETags provide, it&#8217;s better to just remove the ETag altogether.</p>
<p><a href="http://developer.yahoo.com/performance/rules.html#etags">http://developer.yahoo.com/performance/rules.html#etags</a>
</p></blockquote>
<p>Add the following code to your .htaccess file to remove ETag headers.</p>
<pre class="brush: plain; title: ; notranslate">
# Turn off ETags
FileETag None
Header unset ETag
</pre>
<h2>Set Expires headers with ExpiresByType (optional)</h2>
<p>If your host has the <code>mod_expires</code> module enabled, you can specify Expires headers by file type.  Godaddy does not have this module enabled.</p>
<pre class="brush: plain; title: ; notranslate">
# Set Expires headers
ExpiresActive On
ExpiresDefault &quot;access plus 1 year&quot;
ExpiresByType text/html &quot;access plus 1 second&quot;
ExpiresByType image/gif &quot;access plus 2592000 seconds&quot;
ExpiresByType image/jpeg &quot;access plus 2592000 seconds&quot;
ExpiresByType image/png &quot;access plus 2592000 seconds&quot;
ExpiresByType image/x-icon &quot;access plus 2592000 seconds&quot;
ExpiresByType text/css &quot;access plus 604800 seconds&quot;
ExpiresByType text/javascript &quot;access plus 604800 seconds&quot;
ExpiresByType application/x-javascript &quot;access plus 604800 seconds&quot;
</pre>
<h2>Removing the Last-Modified header in .htaccess (optional)</h2>
<p>I&#8217;m following Google&#8217;s instructions and not removing the Last-Modified header, but if you wanted to do so, you could use:</p>
<pre class="brush: plain; title: ; notranslate">
# Remove Last-Modified header
Header unset Last-Modified
</pre>
<h2>Busting the cache when files change</h2>
<p>What happens when you change files and need to force browsers to load the new files? Christian Johansen offers two methods in his post on <a href="http://cjohansen.no/en/apache/using_a_far_future_expires_header">Using a far future expires header</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2010/07/17/sending-headers-to-leverage-browser-caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to compress .php, .css and .js files without mod_gzip or mod_deflate</title>
		<link>http://www.ardamis.com/2010/07/11/compress-files-without-mod_gzip-or-mod_deflate/</link>
		<comments>http://www.ardamis.com/2010/07/11/compress-files-without-mod_gzip-or-mod_deflate/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 04:42:27 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[godaddy]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[web app]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=753</guid>
		<description><![CDATA[How to speed up page load times by compressing .php, .css and .js files on Apache web hosts that do not have mod_gzip or mod_deflate enabled.]]></description>
			<content:encoded><![CDATA[<p>File compression is possible on Apache web hosts that do not have mod_gzip or mod_deflate enabled, and it&#8217;s easier than you might think.</p>
<p>A great explanation of why compression helps the web deliver a better user experience is at <a href="http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/">betterexplained.com</a>.</p>
<p>Two authoritative articles on the subject are Google&#8217;s <a href="http://code.google.com/speed/page-speed/docs/payload.html#GzipCompression">Performance Best Practices documentation | Enable compression</a> and Yahoo&#8217;s <a href="http://developer.yahoo.com/performance/rules.html#gzip">Best Practices for Speeding Up Your Web Site | Gzip Components</a>.</p>
<h2>Compressing PHP files</h2>
<p>If your Apache server does not have mod_gzip or mod_deflate enabled (Godaddy and JustHost shared hosting, for example), you can use PHP to compress pages on-the-fly.  This is still preferable to sending uncompressed files to the browser, so don&#8217;t worry about the additional work the server has to do to compress the files at each request.  </p>
<h3>Option 1: PHP.INI using zlib.output_compression</h3>
<p>The zlib extension can be used to transparently compress PHP pages on-the-fly if the browser sends an &#8220;Accept-Encoding: gzip&#8221; or &#8220;deflate&#8221; header.  Compression with zlib.output_compression seems to be disabled on most hosts by default, but can be enabled with a custom php.ini file:</p>
<pre class="brush: plain; title: ; notranslate">
[PHP]

zlib.output_compression = On
</pre>
<p>Credit: <a href="http://php.net/manual/en/zlib.configuration.php">http://php.net/manual/en/zlib.configuration.php</a></p>
<p>Check with your host for instructions on how to implement this, and whether you need a php.ini file in each directory.</p>
<h3>Option 2: PHP using ob_gzhandler</h3>
<p>If your host does not allow custom php.ini files, you can add the following line of code to the top of your PHP pages, above the DOCTYPE declaration or first line of output:</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start(&quot;ob_gzhandler&quot;); else ob_start(); ?&gt;
</pre>
<p>Credit: <a href="http://help.godaddy.com/article/4485">GoDaddy.com</a></p>
<p>For WordPress sites, this code would be added to the top of the theme&#8217;s header.php file.</p>
<p>According to php.net, <a href="http://php.net/manual/en/function.ob-gzhandler.php">using zlib.output_compression is preferred over ob_gzhandler()</a>.</p>
<p>For WordPress or other CMS sites, an advantage of zlib.output_compression over the ob_gzhandler method is that all of the .php pages served will be compressed, not just those that contain the global include (eg.: header.php, etc.).</p>
<p>Running both ob_gzhandler and zlib.output_compression at the same time will throw a warning, similar to:</p>
<p><em>Warning: ob_start() [ref.outcontrol]: output handler &#8216;ob_gzhandler&#8217; conflicts with &#8216;zlib output compression&#8217; in /home/path/public_html/ardamis.com/wp-content/themes/mytheme/header.php on line 7</em></p>
<h2>Compressing CSS and JavaScript files</h2>
<p>Because the on-the-fly methods above only work for PHP pages, you&#8217;ll need something else to compress CSS and JavaScript files.  Furthermore, these files typically don&#8217;t change, so there isn&#8217;t a need to compress them at each request.  A better method is to serve pre-compressed versions of these files.  I&#8217;ll describe a few different ways to do this, but in both cases, you&#8217;ll need to add some lines to your .htaccess file to send user agents the gzipped versions if they support the encoding.  This requires that Apache&#8217;s mod_rewrite be enabled (and I think it&#8217;s almost universally enabled).</p>
<h3>Option 1: Compress locally and upload</h3>
<p>CSS and JavaScript files can be gzipped on the workstation, then uploaded along with the uncompressed files.  Use a utility like <a href="http://www.7-zip.org/">7-Zip</a> (quite possibly the best compression software around, and it&#8217;s free) to compress the CSS and JavaScript files using the gzip format (with extension *.gz), then upload them to your server.</p>
<p>For Windows users, here is a handy command to compress all the .css and .js files in the current directory and all sub directories (adjust the path to the 7-Zip executable, Zz.exe, as necessary):</p>
<pre class="brush: plain; title: ; notranslate">
for /R %i in (*.css *.js) do &quot;C:\Program Files (x86)\7-Zip\7z.exe&quot; a -tgzip &quot;%i.gz&quot; &quot;%i&quot; -mx9
</pre>
<p>Note that the above command is to be run from the command line.  The batch file equivalent would be:</p>
<pre class="brush: plain; title: ; notranslate">
for /R %%i in (*.css *.js) do &quot;C:\Program Files (x86)\7-Zip\7z.exe&quot; a -tgzip &quot;%%i.gz&quot; &quot;%%i&quot; -mx9
</pre>
<h3>Option 2: Compress on the server</h3>
<p>If you have shell access, you can run a command to create a gzip copy of each CSS and JavaScript file on your site (or, if you are developing on Linux, you can run it locally):</p>
<pre class="brush: plain; title: ; notranslate">
find . -regex &quot;.*\(css\|js\)$&quot; -exec bash -c 'echo Compressing &quot;{}&quot; &amp;&amp; gzip -c --best &quot;{}&quot; &gt; &quot;{}.gz&quot;' \;
</pre>
<p>This may be a bit too technical for many people, but is also much more convenient.  It is particularly useful when you need to compress a large number of files (as in the case of a WordPress installation with multiple plugins).  Remember to run it every time you automatically update WordPress, your theme, or any plugins, so as to replace the gzip&#8217;d versions of any updated CSS and JavaScript files.</p>
<h3>The .htaccess (for both options)</h3>
<p>Add the following lines to your .htaccess file to identify the user agents that can accept the gzip encoded versions of these files.</p>
<pre class="brush: plain; title: ; notranslate">
&lt;files *.js.gz&gt;
  AddType &quot;text/javascript&quot; .gz
  AddEncoding gzip .gz
&lt;/files&gt;
&lt;files *.css.gz&gt;
  AddType &quot;text/css&quot; .gz
  AddEncoding gzip .gz
&lt;/files&gt;
RewriteEngine on
#Check to see if browser can accept gzip files.
ReWriteCond %{HTTP:accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
#make sure there's no trailing .gz on the url
ReWriteCond %{REQUEST_FILENAME} !^.+\.gz$
#check to see if a .gz version of the file exists.
RewriteCond %{REQUEST_FILENAME}.gz -f
#All conditions met so add .gz to URL filename (invisibly)
RewriteRule ^(.+) $1.gz [QSA,L]
</pre>
<p>Credit: <a href="http://www.opensourcetutor.com/2009/06/01/how-to-compress-css-javascript-an-alternative-to-mod_deflate-or-mod_gzip/">opensourcetutor.com</a></p>
<p>I&#8217;m not sure it&#8217;s still necessary to exclude Safari.</p>
<p>For added benefit, minify the CSS and JavaScript files before gzipping them.  Google&#8217;s excellent <a href="http://code.google.com/speed/page-speed/">Page Speed</a> Firefox/Firebug Add-on makes this very easy.  Yahoo&#8217;s <a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a> is also quite good.</p>
<h2>Verify that your content is being compressed</h2>
<p>Use the nifty Web Page Content Compression Verification tool at <a href="http://www.whatsmyip.org/http_compression/">http://www.whatsmyip.org/http_compression/</a> to confirm that your server is sending the compressed files.</p>
<h2>Speed up page load times for returning visitors</h2>
<p>Compression is only part of the story.  In order to further speed page load times for your returning visitors, you will want to <a href="http://www.ardamis.com/2010/07/17/sending-headers-to-leverage-browser-caching/">send the correct headers to leverage browser caching</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2010/07/11/compress-files-without-mod_gzip-or-mod_deflate/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Upgrading GoDaddy Hosting to PHP 5.x from PHP 4.3.11</title>
		<link>http://www.ardamis.com/2009/07/25/upgrading-godaddy-hosting-to-php-5-x-from-php-4-3-11/</link>
		<comments>http://www.ardamis.com/2009/07/25/upgrading-godaddy-hosting-to-php-5-x-from-php-4-3-11/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 06:21:15 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=327</guid>
		<description><![CDATA[How to configure your GoDaddy linux hosting plan and .htaccess file to run your *.php pages on PHP 5.2.5.]]></description>
			<content:encoded><![CDATA[<p><strong>Update 2/22/2010: It looks like changing .htaccess is no longer necessary.  After you select PHP 5.x, your site will begin using version 5.2.5 without any further configuration.</strong></p>
<p>The following applies to older domains.  As of early 2009, newly purchased linux hosting plans are running PHP 5.2.8, while older plans, once updated, only go up to PHP 5.2.5.  I&#8217;ve had Ardamis.com hosted at GoDaddy since 2005, and quite awhile ago I thought I had upgraded to PHP version 5 from 4.3.11, but tonight I happened to check with phpinfo and found I was still on version 4.</p>
<p>In the unheard of ten minutes that I was on hold waiting for technical support, I figured out how to really run my pages on PHP 5.x (in this case, 5.2.5).</p>
<p>Log in and go to your Hosting Control Center.  You must be running Hosting Configuration 2.0 to go any further, so if you haven&#8217;t touched your domain in years, do that first.</p>
<p>Click on Content, then Add-On Languages.  Next to PHP Version, select PHP 5.x and click Continue.  You&#8217;ll get a message that &#8220;Changing to PHP 5.x may make your PHP files run incorrectly.&#8221;  Highly unlikely these days, but OK, you&#8217;ve been warned.  Notice, too that it says &#8220;PHP 5.x will be <em>activated</em>&#8220;.  Click Update.</p>
<p>It may take awhile for this change to be processed by the server, but once your Account Summary is displaying PHP Version: 5.x, it&#8217;s time for the really important part.</p>
<p>You see, you&#8217;ve only made PHP 5.x available at this point.  Your *.php files are still running in 4.x.  Go ahead and check phpinfo again.  </p>
<p>Now, you could simply edit .htaccess to change the extensions, like so:</p>
<pre class="brush: plain; title: ; notranslate">
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4
</pre>
<p>More details at http://help.godaddy.com/article/1082</p>
<p>But if you&#8217;re squeamish about changing .htaccess yourself, there&#8217;s another way to set 5.x to be the default handler for *.php files.  All the following does, strangely enough, is to add the <code>AddHandler x-httpd-php5 .php</code> to the beginning of your .htaccess file.</p>
<p>Back in the Hosting Control Center, click on Settings, then File Extension.  If the change to 5.x has been completed, you&#8217;ll see at the bottom of the available extensions list, &#8220;Extension -> .php | Runs Under -> PHP 5.x&#8221;  If it&#8217;s not there, stop here and come back in an hour or so.</p>
<p>Click on Custom Extensions at the left.  This should be empty, with a message stating &#8220;No custom extensions have been created.&#8221;</p>
<p>Click on Default Extensions and then click on the Edit button (it looks like a piece of paper and a pencil) to the right of .php | PHP 5.x.  Click on Continue.</p>
<p>Click again on the Custom Extensions button on the left, and you should now see &#8220;Extension -> .php | Runs Under -> PHP 5.x&#8221;.  Check your phpinfo page one more time, and it should report PHP 5.x.</p>
<p>It&#8217;s unfortunate we even have to do this for our older domains, but I asked the tech support guy if I could somehow get on  to PHP 5.2.8, and he said nope, that the newer servers have the more recent version but the older servers are stuck back in 2007.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2009/07/25/upgrading-godaddy-hosting-to-php-5-x-from-php-4-3-11/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>

