<?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>Colin Mollenhour&#039;s Technical Blog &#187; Uncategorized</title>
	<atom:link href="http://colin.mollenhour.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://colin.mollenhour.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 13 Oct 2011 21:08:06 +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>Resolving Magento module dependencies without using the &#8220;depends&#8221; element</title>
		<link>http://colin.mollenhour.com/2011/10/13/resolving-magento-module-dependencies-without-using-the-depends-element/</link>
		<comments>http://colin.mollenhour.com/2011/10/13/resolving-magento-module-dependencies-without-using-the-depends-element/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 21:08:06 +0000</pubDate>
		<dc:creator>colin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://colin.mollenhour.com/?p=160</guid>
		<description><![CDATA[You might someday (or perhaps you already have) come across a case where you want one module to be loaded after another module, but don&#8217;t necessarily want it to depend on the other module. Reasons might be that one config value should override another (such as a model/block/controller rewrite), or one layout should be applied [...]]]></description>
			<content:encoded><![CDATA[<p>You might someday (or perhaps you already have) come across a case where you want one module to be loaded after another module, but don&#8217;t necessarily want it to depend on the other module. Reasons might be that one config value should override another (such as a model/block/controller rewrite), or one layout should be applied after another (such as to remove a block added by the former). There might not <em>actually</em> be a dependence, or perhaps adding a dependence would create a circular dependency. There are two possible solutions for this:</p>
<ol>
<li>Merge the two (or more) module .xml files manually into one .xml file with the proper XML element order.</li>
<li>Name the .xml files (or symlinks a.la. <a href="http://code.google.com/p/module-manager/" title="Module Manager" target="_blank">modman</a>) such that they sort alphabetically in the proper order.</li>
</ol>
<p>The element order within a single file will be stable (SimpleXML), and Magento loads the files alphabetically except that those beginning with Mage_ come first. Problem solved.</p>
<p>Example:</p>
<pre>
Before:
  app/etc/modules/My_Module.xml
  app/etc/modules/Their_Module.xml
After:
  app/etc/modules/50_Their_Module.xml
  app/etc/modules/60_My_Module.xml
</pre>
<p>Now &#8220;My_Module&#8221; is loaded after &#8220;Their_Module&#8221; so I can override their config and/or layout without modifying their files and without My_Module depending on Their_Module!</p>
]]></content:encoded>
			<wfw:commentRss>http://colin.mollenhour.com/2011/10/13/resolving-magento-module-dependencies-without-using-the-depends-element/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross-SCM (git and subversion) projects with modman</title>
		<link>http://colin.mollenhour.com/2011/03/03/cross-scm-git-and-subversion-projects-with-modman/</link>
		<comments>http://colin.mollenhour.com/2011/03/03/cross-scm-git-and-subversion-projects-with-modman/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 05:10:39 +0000</pubDate>
		<dc:creator>colin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://colin.mollenhour.com/?p=139</guid>
		<description><![CDATA[I recently had a need to include some code from two subversion repositories in a git-based project. A bit of Googling brought me to the disappointing conclusion that there is no easy maintenance-free way of doing this with git.. Modman to the rescue! With a simple one-liner added to my modman file I can accomplish [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a need to include some code from two subversion repositories in a git-based project. A bit of Googling brought me to the disappointing conclusion that there is no easy maintenance-free way of doing this with git.. <a href="http://code.google.com/p/module-manager/">Modman to the rescue!</a> With a simple one-liner added to my modman file I can accomplish what is essentially an svn:externals declaration in my git-based project, or a subversion repository as a git submodule! Behold:</p>
<p>
EDIT: Updated to use multi-line continuations for readability.</p>
<pre class="brush: plain;">
# Substitute for svn:externals
@shell \
  SRC=https://example.com/source/magento/common; \
  DEST=modules; \
  if [ -d $DEST/.svn ]; then \
    svn update $DEST; \
  else \
    svn checkout $SRC $DEST; \
  fi

# Import subversion-based modules
@import    modules/Foo
@import    modules/Bar
</pre>
<p>
Now, when I clone the module (git is supported natively as of 1.1.0) or any time I run an update, deploy or repair, the subversion modules will be checked out or updated as well. So, if you ever need to mix and match SCM&#8217;s, go right ahead. I still recommend the use of git submodules for all-git projects and svn:externals for all-subversion projects, of course.
</p>
<p>
I&#8217;ll consider adding a builtin function that tidies up the above and handles things like switching urls..</p>
]]></content:encoded>
			<wfw:commentRss>http://colin.mollenhour.com/2011/03/03/cross-scm-git-and-subversion-projects-with-modman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Right Way to Optimize Apache&#8217;s .htaccess Files</title>
		<link>http://colin.mollenhour.com/2010/06/30/the-right-way-to-optimize-apaches-htaccess-files/</link>
		<comments>http://colin.mollenhour.com/2010/06/30/the-right-way-to-optimize-apaches-htaccess-files/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 23:47:09 +0000</pubDate>
		<dc:creator>colin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://colin.mollenhour.com/?p=127</guid>
		<description><![CDATA[While researching Magento performance optimizations you have probably already read about how to optimize Apache&#8217;s configuration by moving your configuration directives into the configuration files and out of the .htaccess files. Of course you need root to do this, but assuming you can, there are still very very wrong ways to do this that will [...]]]></description>
			<content:encoded><![CDATA[<p>
While researching Magento performance optimizations you have probably already read about how to optimize Apache&#8217;s configuration by moving your configuration directives into the configuration files and out of the .htaccess files. Of course you need root to do this, but assuming you can, there are still very very wrong ways to do this that will result in no real performance gains, leave gaping security holes, and consume more time than necessary. Read on, a handy script for solving these problems and before and after performance benchmarks to prove the gains are included.
</p>
<p><span id="more-127"></span></p>
<h2>Mistake #1</h2>
<p>If you move your .htaccess contents into the apache config files that is great, but if you forget to disable .htaccess files using <code>AllowOverride None</code> then you&#8217;ve entirely defeated the purpose! The reason this technique can result in performance gains is that it allows the server to ignore the .htaccess files which means fewer directory traversals and fewer file reads with each request. One page load probably results in 20-100 HTTP requests to your Apache server. If you have deeply nested files (all of those cached product images and skin images come to mind) then this results in a lot of disk access. So, you must disable the .htaccess files completely with <code>AllowOverride None</code>! Which brings me to the second major mistake that people can make&#8230;
</p>
<h2>Mistake #2</h2>
<p>
Now that you&#8217;ve disabled .htaccess, guess what? Those .htaccess files had a purpose.. For example, to deny access to your <code>app/etc/local.xml</code> config file!! Great way to expose your database password, let&#8217;s just hope the user is a localhost-only user and you don&#8217;t re-use passwords&#8230; Also, in <code>downloader/.htaccess</code> for example, compression is disabled so that the Magento Connect console can circumvent Apache&#8217;s buffering to display the console output as it occurs. There are others as well. Point is, now you have to move all of these .htaccess files into your apache config. Ugh.. Which brings me to my last point&#8230;
</p>
<h2>Mistake #3</h2>
<p>
It doesn&#8217;t have to be difficult! I&#8217;ve written a bash script (buildhtaccess.sh, see below) which provides you an easy way to benefit from this tweak. In essence the following script will find all of your .htaccess files and compile them into one file which can then be included in your Apache config with only a few lines. If you modify an .htaccess file or a new one is installed by an extension, re-run the script and reload the apache config.
</p>
<h2>Tutorial</h2>
<p>First, download and run the script to generate your .htaccess-combined file.</p>
<pre class="brush: plain;">
$ cd &lt;webroot&gt;
$ wget http://gist.github.com/raw/459311/buildhtaccess.sh
$ bash buildhtaccess.sh
</pre>
</p>
<p>Next, edit your apache config file. Find the <code>&lt;VirtualHost&gt;</code> directive and at the end of it add the following:</p>
<pre class="brush: plain;">
  # Include combined Magento .htaccess files
  &lt;Directory /your_webroot_here&gt;
    AllowOverride None
  &lt;/Directory&gt;
  Include /your_webroot_here/.htaccess-combined
</pre>
</p>
<p>
Lastly, run a graceful reload of the Apache config. A full restart is not necessary. Now you&#8217;re done.
</p>
<h2>Code</h2>
<p>And here is the code for generating the .htaccess-combined file:<br />
<script src="http://gist.github.com/459311.js?file=buildhtaccess.sh"></script>
</p>
<h2>Benchmarks</h2>
<p>For my benchmark I ran &#8220;ab&#8221; (apache bench) since it is quick and easy but admittedly not the best for benchmarking overall site performance. In this case apache bench is going to under state the value of this tweak since one page load in a browser will result in repeated hits on the webserver, all of which will be affected by this optimization. So, I benchmarked on /errors/503.php so that the database is not factored but PHP code is still run. Specifically, I used <code>$ ab -n 1000 -c 20 .../errors/503.php</code>.<br/><br />
Before: <b>~3000 requests per second (3018 max)</b><br/><br />
After: <b>~4600 requests per second (5030 max)</b><br/></p>
<p>That&#8217;s a pretty nice improvement. Unfortunately it is only substantial with fast requests such as the error pages and static files but it should definitely reduce disk contention on a busy server and increase scalability, but probably not do a whole lot for user-experience on a low-contention server.
</p>
<h5>I&#8217;d love to see your results, please post them in the comments!</h5>
]]></content:encoded>
			<wfw:commentRss>http://colin.mollenhour.com/2010/06/30/the-right-way-to-optimize-apaches-htaccess-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My humble website is born&#8230;</title>
		<link>http://colin.mollenhour.com/2008/09/11/my-humble-website-is-born/</link>
		<comments>http://colin.mollenhour.com/2008/09/11/my-humble-website-is-born/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 09:32:33 +0000</pubDate>
		<dc:creator>colin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://colin.mollenhour.com/?p=16</guid>
		<description><![CDATA[FP! Never thought I'd say that..]]></description>
			<content:encoded><![CDATA[<p>Ok, so what kind of web developer doesn&#8217;t have a website? <strong>Me</strong>, but not anymore. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://colin.mollenhour.com/2008/09/11/my-humble-website-is-born/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

