<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Advanced WordPress wp-config.php Tweaks</title>
	<atom:link href="http://www.askapache.com/wordpress/advanced-wp-config-php-tweaks.html/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.askapache.com/wordpress/advanced-wp-config-php-tweaks.html</link>
	<description>Advanced Web Development</description>
	<lastBuildDate>Wed, 18 Nov 2009 23:28:48 -0500</lastBuildDate>
	
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: AskApache</title>
		<link>http://www.askapache.com/wordpress/advanced-wp-config-php-tweaks.html#comment-105061</link>
		<dc:creator>AskApache</dc:creator>
		<pubDate>Sun, 11 Oct 2009 05:58:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.askapache.com/?p=3341#comment-105061</guid>
		<description>&lt;p&gt;&lt;strong&gt;@ Ryan&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;On the other hand, the rewrite engine can create higher server load than responding to the 304 headers.  304 If-Modified-Since was designed to reduce bandwidth for the server and for the client by not having to send the file if it has not been modified. The bandwidth and load used by a 304 is less than the load caused by using the rewrite engine in most cases (from my own studies, YMMV).&lt;/blockquote&gt;
&lt;p&gt;Yes I suppose this could happen, but if you set it up the way I outline then the only way is if no-one ever visited your site twice, i.e. no 304&#039;s ever being sent.  Otherwise mod_rewrite is very friendly for simple rewrites like this.   But keep in mind you don&#039;t have to use mod_rewrite, this method would work perfectly if you renamed your files for real.  The rewriting just adds the ability to not have to rename the actual files.  I could see a server using lighthttpd or something similar benefitting from that.  304&#039;s will always produce more server load, but the biggest problem is the network hogging.&lt;/p&gt;

&lt;blockquote cite=&quot;http://www.ietf.org/rfc/rfc2068&quot;&gt;
&lt;p&gt;&lt;a href=&quot;http://www.ietf.org/rfc/rfc2068&quot; rel=&quot;nofollow&quot;&gt;Validation Model&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When a cache has a stale entry that it would like to use as a response to a client&#039;s request, it first has to check with the origin server (or possibly an intermediate cache with a fresh response) to see if its cached entry is still usable. &lt;em&gt;We call this &quot;validating&quot; the cache entry.  Since we do not want to have to pay the overhead of retransmitting the full response if the cached entry is good, and we do not want to pay the overhead of an extra round trip if the cached entry is invalid, the HTTP/1.1 protocol supports the use of conditional methods.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Basically Ryan you remove validation information (last-modified, etags, content-md5) for your files you want to cache in this way, and then you specify a far-futures-expires cache-control header.  Like for a month.  Because your entity is cached client-side with no validation information, no 304&#039;s of any kind will ever be sent to your server until the expires runs out, OR if you rename the entity.&lt;/p&gt;
&lt;p&gt;Instead your files (like my apache.js and apache.css) can be cached on the clients browser in the purest sense, meaning you are almost creating your files in an offline mode similar to google gears.  Of course this would be worthless for most people unless their was a way to force user-agents and clients to refresh their caches whenever we want, without them ever making conditional requests.   To do that you just setup your .html file that links to the .js or .css file to only be cached for a day, or an hour, whatever, and so when you update your js or css file you just rename it in the .html which will force the clients browser to re-download the new file.&lt;/p&gt;
&lt;p&gt;It&#039;s hard to explain, you really need to get WireShark or check out HTTP Headers in Firefox to see.&lt;/p&gt;

&lt;blockquote&gt;As to the use of the query string, I’m aware of the HTTP specifications, and I’m aware of the use of them. However, using a “fake” query string is no more of a hack than using non-existent (as in, not mapping directly to the filesystem) URLs.&lt;/blockquote&gt;
&lt;p&gt;Agreed.  I used to use the query string hack years ago when I first started, and it is a cool hack.. but it penalizes any file that uses it (especially intermediary caches).  Mapping non-existent files to the filesystem does result in some performance loss (like bits compared to gbits of net traffic and cpu from 304 and checksum validations), and it is certainly a hacky hack for those not familiar with mod_rewrite.  WordPress will no longer use the query string hack in the future...  these hacks are meant for development only, not for production.  It&#039;s just nuanced enough that developers aren&#039;t aware.  Then you see sites like digg that really depend on their bandwidth and system moving away from the query hack to the best-practice I outline.&lt;/p&gt;
&lt;p&gt;Digg uses CDN of course and all that but the way they implemented it can be done without mod_rewrite.   Put your static files in a subdirectory, and when you make a change to the files just rename the directory.&lt;/p&gt;
&lt;pre&gt;http://media.digg.com/css/282/global.css&lt;/pre&gt;


&lt;blockquote cite=&quot;http://www.ietf.org/rfc/rfc3230.txt&quot;&gt;
&lt;p&gt;&lt;a href=&quot;http://www.ietf.org/rfc/rfc3230.txt&quot; rel=&quot;nofollow&quot;&gt;1.1 Other limitations of HTTP/1.1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Checksums are not free&lt;/strong&gt; (&lt;em&gt;Used by IP/TCP/HTTP/and of course, conditional requests and validation header generation&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Computing a digest (&lt;em&gt;validator&lt;/em&gt;) takes CPU resources&lt;/strong&gt; (&lt;em&gt;disk resources&lt;/em&gt;) and might &lt;strong&gt;add latency to the generation&lt;/strong&gt; of a message.  (Some of &lt;strong&gt;these costs can be avoided by careful caching at the sender&#039;s end&lt;/strong&gt;, but in many cases such a cache would not have a useful hit ratio.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Transmitting a digest consumes HTTP header space&lt;/strong&gt; (and therefore &lt;strong&gt;increases latency and network bandwidth&lt;/strong&gt; requirements.)&lt;/p&gt;
&lt;p class=&quot;inote&quot;&gt;&lt;strong&gt;If the message recipient does not intend to use the digest, why should the message sender waste resources computing and sending it?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That pretty much says it all.  RFC&#039;s can help you figure it out, especially the caching information in &lt;a href=&quot;http://www.ietf.org/rfc/rfc2068&quot; rel=&quot;nofollow&quot;&gt;RFC 2068&lt;/a&gt;&lt;/p&gt;


&lt;strong&gt;Download WireShark and you will quickly and easily be able to see what I&#039;m talking about.  I&#039;ll probably post an article on this eventually.. as this is one of my favorite topics.  Here is what RFC3230 said about validation and checksums, which is a pretty good summary of the optimizations I am using on this site if you care to YSlow it.&lt;/strong&gt;</description>
		<content:encoded><![CDATA[<p><strong>@ Ryan</strong></p>
<blockquote><p>On the other hand, the rewrite engine can create higher server load than responding to the 304 headers.  304 If-Modified-Since was designed to reduce bandwidth for the server and for the client by not having to send the file if it has not been modified. The bandwidth and load used by a 304 is less than the load caused by using the rewrite engine in most cases (from my own studies, YMMV).</p></blockquote>
<p>Yes I suppose this could happen, but if you set it up the way I outline then the only way is if no-one ever visited your site twice, i.e. no 304&#8217;s ever being sent.  Otherwise mod_rewrite is very friendly for simple rewrites like this.   But keep in mind you don&#8217;t have to use mod_rewrite, this method would work perfectly if you renamed your files for real.  The rewriting just adds the ability to not have to rename the actual files.  I could see a server using lighthttpd or something similar benefitting from that.  304&#8217;s will always produce more server load, but the biggest problem is the network hogging.</p>
<blockquote cite="http://www.ietf.org/rfc/rfc2068">
<p><a href="http://www.ietf.org/rfc/rfc2068" rel="nofollow">Validation Model</a></p>
<p>When a cache has a stale entry that it would like to use as a response to a client&#8217;s request, it first has to check with the origin server (or possibly an intermediate cache with a fresh response) to see if its cached entry is still usable. <em>We call this &#8220;validating&#8221; the cache entry.  Since we do not want to have to pay the overhead of retransmitting the full response if the cached entry is good, and we do not want to pay the overhead of an extra round trip if the cached entry is invalid, the HTTP/1.1 protocol supports the use of conditional methods.</em></p>
</blockquote>
<p>Basically Ryan you remove validation information (last-modified, etags, content-md5) for your files you want to cache in this way, and then you specify a far-futures-expires cache-control header.  Like for a month.  Because your entity is cached client-side with no validation information, no 304&#8217;s of any kind will ever be sent to your server until the expires runs out, OR if you rename the entity.</p>
<p>Instead your files (like my apache.js and apache.css) can be cached on the clients browser in the purest sense, meaning you are almost creating your files in an offline mode similar to google gears.  Of course this would be worthless for most people unless their was a way to force user-agents and clients to refresh their caches whenever we want, without them ever making conditional requests.   To do that you just setup your .html file that links to the .js or .css file to only be cached for a day, or an hour, whatever, and so when you update your js or css file you just rename it in the .html which will force the clients browser to re-download the new file.</p>
<p>It&#8217;s hard to explain, you really need to get WireShark or check out HTTP Headers in Firefox to see.</p>
<blockquote><p>As to the use of the query string, I’m aware of the HTTP specifications, and I’m aware of the use of them. However, using a “fake” query string is no more of a hack than using non-existent (as in, not mapping directly to the filesystem) URLs.</p></blockquote>
<p>Agreed.  I used to use the query string hack years ago when I first started, and it is a cool hack.. but it penalizes any file that uses it (especially intermediary caches).  Mapping non-existent files to the filesystem does result in some performance loss (like bits compared to gbits of net traffic and cpu from 304 and checksum validations), and it is certainly a hacky hack for those not familiar with mod_rewrite.  WordPress will no longer use the query string hack in the future&#8230;  these hacks are meant for development only, not for production.  It&#8217;s just nuanced enough that developers aren&#8217;t aware.  Then you see sites like digg that really depend on their bandwidth and system moving away from the query hack to the best-practice I outline.</p>
<p>Digg uses CDN of course and all that but the way they implemented it can be done without mod_rewrite.   Put your static files in a subdirectory, and when you make a change to the files just rename the directory.</p>
<pre>http://media.digg.com/css/282/global.css</pre>
<blockquote cite="http://www.ietf.org/rfc/rfc3230.txt">
<p><a href="http://www.ietf.org/rfc/rfc3230.txt" rel="nofollow">1.1 Other limitations of HTTP/1.1</a></p>
<p><strong>Checksums are not free</strong> (<em>Used by IP/TCP/HTTP/and of course, conditional requests and validation header generation</em>).</p>
<p><strong>Computing a digest (<em>validator</em>) takes CPU resources</strong> (<em>disk resources</em>) and might <strong>add latency to the generation</strong> of a message.  (Some of <strong>these costs can be avoided by careful caching at the sender&#8217;s end</strong>, but in many cases such a cache would not have a useful hit ratio.)</p>
<p><strong>Transmitting a digest consumes HTTP header space</strong> (and therefore <strong>increases latency and network bandwidth</strong> requirements.)</p>
<p class="inote"><strong>If the message recipient does not intend to use the digest, why should the message sender waste resources computing and sending it?</strong></p>
</blockquote>
<p>That pretty much says it all.  RFC&#8217;s can help you figure it out, especially the caching information in <a href="http://www.ietf.org/rfc/rfc2068" rel="nofollow">RFC 2068</a></p>
<p><strong>Download WireShark and you will quickly and easily be able to see what I&#8217;m talking about.  I&#8217;ll probably post an article on this eventually.. as this is one of my favorite topics.  Here is what RFC3230 said about validation and checksums, which is a pretty good summary of the optimizations I am using on this site if you care to YSlow it.</strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan McCue</title>
		<link>http://www.askapache.com/wordpress/advanced-wp-config-php-tweaks.html#comment-104938</link>
		<dc:creator>Ryan McCue</dc:creator>
		<pubDate>Tue, 06 Oct 2009 06:16:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.askapache.com/?p=3341#comment-104938</guid>
		<description>&lt;p&gt;&lt;strong&gt;@ AskApache&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On the other hand, the rewrite engine can create higher server load than responding to the 304 headers.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;304 If-Modified-Since&lt;/code&gt; was designed to &lt;em&gt;reduce&lt;/em&gt; bandwidth for the server and for the client by not having to send the file if it has not been modified. The bandwidth and load used by a 304 is less than the load caused by using the rewrite engine in most cases (from my own studies, YMMV).&lt;/p&gt;

&lt;p&gt;As to the use of the query string, I&#039;m aware of the HTTP specifications, and I&#039;m aware of the use of them. However, using a &quot;fake&quot; query string is no more of a hack than using non-existent (as in, not mapping directly to the filesystem) URLs.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p><strong>@ AskApache</strong></p>
<p>On the other hand, the rewrite engine can create higher server load than responding to the 304 headers.</p>
<p><code>304 If-Modified-Since</code> was designed to <em>reduce</em> bandwidth for the server and for the client by not having to send the file if it has not been modified. The bandwidth and load used by a 304 is less than the load caused by using the rewrite engine in most cases (from my own studies, YMMV).</p>
<p>As to the use of the query string, I&#8217;m aware of the HTTP specifications, and I&#8217;m aware of the use of them. However, using a &#8220;fake&#8221; query string is no more of a hack than using non-existent (as in, not mapping directly to the filesystem) URLs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AskApache</title>
		<link>http://www.askapache.com/wordpress/advanced-wp-config-php-tweaks.html#comment-104919</link>
		<dc:creator>AskApache</dc:creator>
		<pubDate>Mon, 05 Oct 2009 15:25:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.askapache.com/?p=3341#comment-104919</guid>
		<description>&lt;strong&gt;@ Ryan&lt;/strong&gt;

&lt;p&gt;It&#039;s actually not a good idea, it is a great idea.  The problem with the query string method is pretty large, and it always frustrates me when I see a site using it, as that tells me the developers don&#039;t know much about the HTTP protocol.&lt;/p&gt;

&lt;p&gt;The query string is made for one reason, to pass session specific information from the client browser back to the server.  Many urls use this correctly, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/wp-login.php?action=register&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/wp-login.php?action=register&amp;redirect_to=/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And depending on the action and GET variables in the query string of the request, the server responds with a different page.&lt;/p&gt;

&lt;p&gt;This simple method of responding differently based on the query string is exactly the way it is supposed to be used, and that is also the reason that cache&#039;s and cache software that adheres to the HTTP protocol correctly &lt;strong&gt;DO NOT CACHE URLS WITH QUERY STRINGS&lt;/strong&gt;.&lt;/p&gt;  

&lt;p&gt;Just like you wouldn&#039;t expect or want a proxy or cache to cache a POST to a form you shouldn&#039;t expect a proxy or cache to cache a GET request that contains a query string. &lt;/p&gt; 

&lt;p&gt;It&#039;s not some kind of bias or anything, thats just the way the protocol was designed and specified. &lt;/p&gt; 

&lt;p&gt;The sad thing is that some developer a long time ago noticed that when a query string was added to a url, the file wasn&#039;t loaded from cache but was re-requested.  Without looking up the protocol specs or looking at any caching source code they decided that this was an effective way to implement a poor-mans-version control.  Not because it was effective but because it was easy and faster than fast.&lt;/p&gt;

&lt;p&gt;Without examining the HTTP protocol level of the communication that takes place between a browsing client and a query string hacked resource, a developer wouldn&#039;t ever realize that in fact all the resources that have a query string on them do not get cached for real.  They do get cached when the caching headers are present, the problem is that having a query string in the url triggers rules in the browsers, caches, and proxies that are based on HTTP specifications that require any cached resource containing a query string to be &lt;strong&gt;re-validated on each and every request&lt;/strong&gt;.  This is done by sending a 304 If-Modified-Since, or other validation request to the origin server to check if the query string resource has been modified or changed since the last request.&lt;/p&gt;

&lt;p&gt;That is the purpose of the E-Tag, Last-Modified, Content-MD5, and other validation response headers and they need to be checked by the origin server and compared to the 304 request for each request.&lt;/p&gt;

&lt;p&gt;When I first discovered this new method back in 2005, and started telling everyone about it, I got into this exact discussion over and over, a lot of the pros checked it out and found out I was right, most developers just didn&#039;t want to change what they were doing, I call it lazy.&lt;/p&gt;

&lt;p&gt;digg.com was a notorious user of the query string hack, and after discussions with them they discovered how much bandwidth and CPU and Disk IO they were wasting on these requests due to doing things against RFC/IETF Specs, and they changed.  Now you can go look at digg.com&#039;s source code and you can see a variation on this same technique.&lt;/p&gt;

&lt;pre&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://media.digg.com/css/277/global.css&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://media.digg.com/css/277/lightbox.css&quot; /&gt;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p><strong>@ Ryan</strong></p>
<p>It&#8217;s actually not a good idea, it is a great idea.  The problem with the query string method is pretty large, and it always frustrates me when I see a site using it, as that tells me the developers don&#8217;t know much about the HTTP protocol.</p>
<p>The query string is made for one reason, to pass session specific information from the client browser back to the server.  Many urls use this correctly, like:</p>
<ul>
<li><code>/wp-login.php?action=register</code></li>
<li><code>/wp-login.php?action=register&#038;redirect_to=/</code></li>
</ul>
<p>And depending on the action and GET variables in the query string of the request, the server responds with a different page.</p>
<p>This simple method of responding differently based on the query string is exactly the way it is supposed to be used, and that is also the reason that cache&#8217;s and cache software that adheres to the HTTP protocol correctly <strong>DO NOT CACHE URLS WITH QUERY STRINGS</strong>.</p>
<p>Just like you wouldn&#8217;t expect or want a proxy or cache to cache a POST to a form you shouldn&#8217;t expect a proxy or cache to cache a GET request that contains a query string. </p>
<p>It&#8217;s not some kind of bias or anything, thats just the way the protocol was designed and specified. </p>
<p>The sad thing is that some developer a long time ago noticed that when a query string was added to a url, the file wasn&#8217;t loaded from cache but was re-requested.  Without looking up the protocol specs or looking at any caching source code they decided that this was an effective way to implement a poor-mans-version control.  Not because it was effective but because it was easy and faster than fast.</p>
<p>Without examining the HTTP protocol level of the communication that takes place between a browsing client and a query string hacked resource, a developer wouldn&#8217;t ever realize that in fact all the resources that have a query string on them do not get cached for real.  They do get cached when the caching headers are present, the problem is that having a query string in the url triggers rules in the browsers, caches, and proxies that are based on HTTP specifications that require any cached resource containing a query string to be <strong>re-validated on each and every request</strong>.  This is done by sending a 304 If-Modified-Since, or other validation request to the origin server to check if the query string resource has been modified or changed since the last request.</p>
<p>That is the purpose of the E-Tag, Last-Modified, Content-MD5, and other validation response headers and they need to be checked by the origin server and compared to the 304 request for each request.</p>
<p>When I first discovered this new method back in 2005, and started telling everyone about it, I got into this exact discussion over and over, a lot of the pros checked it out and found out I was right, most developers just didn&#8217;t want to change what they were doing, I call it lazy.</p>
<p>digg.com was a notorious user of the query string hack, and after discussions with them they discovered how much bandwidth and CPU and Disk IO they were wasting on these requests due to doing things against RFC/IETF Specs, and they changed.  Now you can go look at digg.com&#8217;s source code and you can see a variation on this same technique.</p>
<pre>&lt;link rel="stylesheet" type="text/css" href="http://media.digg.com/css/277/global.css" /&gt;
&lt;link rel="stylesheet" type="text/css" href="http://media.digg.com/css/277/lightbox.css" /&gt;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan McCue</title>
		<link>http://www.askapache.com/wordpress/advanced-wp-config-php-tweaks.html#comment-104865</link>
		<dc:creator>Ryan McCue</dc:creator>
		<pubDate>Sat, 03 Oct 2009 12:02:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.askapache.com/?p=3341#comment-104865</guid>
		<description>The &lt;code&gt;ASKAPACHE_LOCK&lt;/code&gt; is a good idea, but a better way to do it is the way WordPress (and many other projects) do: Use a query string like &lt;code&gt;?v=1&lt;/code&gt; instead.</description>
		<content:encoded><![CDATA[<p>The <code>ASKAPACHE_LOCK</code> is a good idea, but a better way to do it is the way WordPress (and many other projects) do: Use a query string like <code>?v=1</code> instead.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
