<?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>Defective Semantics &#187; http</title>
	<atom:link href="http://scarff.id.au/blog/tag/http/feed/" rel="self" type="application/rss+xml" />
	<link>http://scarff.id.au</link>
	<description>Dean Scarff's perpetual struggle with technology, and other anecdotes</description>
	<lastBuildDate>Sun, 05 Sep 2010 04:34:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Apache 304 and mod_deflate revisited</title>
		<link>http://scarff.id.au/blog/2009/apache-304-and-mod_deflate-revisited/</link>
		<comments>http://scarff.id.au/blog/2009/apache-304-and-mod_deflate-revisited/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 03:51:42 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[rfc2616]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=290</guid>
		<description><![CDATA[<p>Last year I commented on how mod_deflate breaks the cache validation model.  Essentially the problem has been addressing two issues:</p>
<ul>
<li>Apache bug #39727, RFC 2616 requires unique strong entity tags for every entity.  Presumably this means after Content-Encoding (but not Transfer-Encoding).  The fix was for deflate to add &#8220;-gzip&#8221; to the ETag.</li>
<li>Apache bug #45023 concerns Apache not being able to recognise the transformed ETag (with the -gzip) as the same entity, and hence not sending 304s when it should have.</li>
</ul>
<p>So in January 2008, a change was committed to fix #39727, which introduced #45023.  Now in April this year, it was reversed to fix #45023.  I agree with the priorities here; no caching is much worse for web performance.</p>
<p>As Roy Fielding pointed out the correct way to deal with this issue is to stop abusing Content-Encoding for performance-compression and start using Transfer-Encoding; pity browsers and HTTP&#8230; <a href="http://scarff.id.au/blog/2009/apache-304-and-mod_deflate-revisited/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>Last year I commented on how <a href="/blog/2008/apache-304s-and-mod_deflate/">mod_deflate breaks the cache validation model</a>.  Essentially the problem has been addressing two issues:</p>
<ul>
<li><a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=39727">Apache bug #39727</a>, <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">RFC 2616 requires unique strong entity tags</a> for every entity.  Presumably this means after Content-Encoding (but not Transfer-Encoding).  The fix was for deflate to add &#8220;-gzip&#8221; to the ETag.</li>
<li><a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=45023">Apache bug #45023</a> concerns Apache not being able to recognise the transformed ETag (with the -gzip) as the same entity, and hence not sending 304s when it should have.</li>
</ul>
<p>So in January 2008, a change was committed to fix #39727, which introduced #45023.  Now in April this year, it was reversed to fix #45023.  I agree with the priorities here; no caching is much worse for web performance.</p>
<p>As <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=39727#c31">Roy Fielding pointed out</a> the correct way to deal with this issue is to stop abusing Content-Encoding for performance-compression and start using Transfer-Encoding; pity browsers and HTTP servers haven&#8217;t got there yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2009/apache-304-and-mod_deflate-revisited/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter not sending 304s</title>
		<link>http://scarff.id.au/blog/2008/twitter-not-sending-304s/</link>
		<comments>http://scarff.id.au/blog/2008/twitter-not-sending-304s/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 05:10:00 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=140</guid>
		<description><![CDATA[<p>The twitter JSON API that I&#8217;ve been using for my status widget has a caching problem, which has caused it to be broken in Opera for a while now.  Opera is quite aggressive in re-using its cache (which IMHO is a good thing).  However, bad things happen when webservices deviate from the HTTP cache validation model.  Twitter is recognising that the browser should be hitting its cache, but its response is broken.</p>
<p>Here&#8217;s how it goes:</p>
<ol>
<li>Load up the JSON document for the first time with an empty cache.</li>
<li>Twitter sends a Last-Modified header and the expected JSON document.</li>
<li>Refresh the document (in Opera, hit enter in the address bar as opposed to clicking the Reload button, since the latter forces a cache refresh).  Opera sends an If-Modified-Since header.</li>
<li>Twitter (presumably) recognises that the last status update was not after the browser&#8217;s cache timestamp.  It sends a degenerate response</li></ol><p>&#8230; <a href="http://scarff.id.au/blog/2008/twitter-not-sending-304s/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>The twitter JSON <a href="http://apiwiki.twitter.com/REST+API+Documentation#HTTPRequests">API</a> that I&#8217;ve been using for my status widget has a caching problem, which has caused it to be broken in Opera for a while now.  Opera is quite aggressive in re-using its cache (which IMHO is a good thing).  However, bad things happen when webservices deviate from the HTTP cache validation model.  Twitter is recognising that the browser should be hitting its cache, but its response is broken.</p>
<p>Here&#8217;s how it goes:</p>
<ol>
<li>Load up the <a href="http://twitter.com/statuses/user_timeline/p00ya.json?count=1">JSON document</a> for the first time with an empty cache.</li>
<li>Twitter sends a Last-Modified header and the expected JSON document.</li>
<li>Refresh the document (in Opera, hit enter in the address bar as opposed to clicking the Reload button, since the latter forces a cache refresh).  Opera sends an If-Modified-Since header.</li>
<li>Twitter (presumably) recognises that the last status update was not after the browser&#8217;s cache timestamp.  It sends a degenerate response entity: &#8220;<code>[]</code>&#8220;; an empty array in javascript, with <strong>a 200 OK status</strong>.</li>
</ol>
<p>To test this from a shell:</p>
<pre class="codeblock sh">
url='http://twitter.com/statuses/user_timeline/p00ya.json?count=1&amp;callback=f'
lm="$(wget --debug $url 2>&amp;1 \
 |grep '^Last-Modified:' \
 |sed -e 's/Last-Modified/If-Modified-Since/' \
 |tr -d '\n\r')"
[ x != "x$lm" ] &amp;&amp; \
  wget -nv --save-headers -O - --header="$lm" $url
</pre>
<p>The brokeness comes from the half-baked response.  A 200 OK status code would be fine if the full JSON object was written out.  A 304 status code with any kind of entity would be fine too.  The empty array might even prevent breakage in user-agents that don&#8217;t handle 304s (but do send If-Modified-Since? wtf?).  Sending a 200 response <strong>overwrites the correct cached entity</strong>, replacing it with the degenerate response.</p>
<p>Firefox seems to be unaffected since it doesn&#8217;t cache the document at all and so doesn&#8217;t send the If-Modified-Since header.</p>
<p>One workaround is to use something like jQuery&#8217;s cache breaking capability (where it adds some random tokens to the URL each time).  <del datetime="2008-09-21T05:49:42+00:00">I refuse</del>.  Just remember the widget breakage wasn&#8217;t my fault!</p>
<p>A separate issue is that it seemed to break Opera quite badly.  Perhaps it was because I&#8217;m using jQuery&#8217;s <a href="http://docs.jquery.com/Events/ready">ready event</a>, but Opera hangs as if the XHR was synchronous.  The document wouldn&#8217;t receive any events (no mouse-wheel scrolling).  I&#8217;ve got no idea why though; my callback functions are robust enough to handle being passed the empty array twitter calls them with, and I wasn&#8217;t getting any exceptions.</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2008/twitter-not-sending-304s/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache 304s and mod_deflate</title>
		<link>http://scarff.id.au/blog/2008/apache-304s-and-mod_deflate/</link>
		<comments>http://scarff.id.au/blog/2008/apache-304s-and-mod_deflate/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 12:18:59 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[http]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=39</guid>
		<description><![CDATA[<p>The deflate output filter in Apache breaks Apache&#8217;s handling of the HTTP cache validation model.  It won&#8217;t send an HTTP 304 status if mod_deflate is actively filtering the response, even if the Etag and Last-Modified allow it to.  I asked, and apparently this is a known issue.  I might have to wait until after exams before making a patch for this one.</p>
<p>In its current state, this introduces a tradeoff for large, uncompressed static files (like CSS and Javascript):</p>
<ul>
<li>gzip stuff, and you improve site performance the first time someone visits, but it never gets any faster.</li>
<li>allow Apache to send 304 statuses, let the user have a slow load on their first visit, but celebrate as they hit their cache thereafter</li>
</ul>
<p>The second option looks more attractive.</p>
]]></description>
			<content:encoded><![CDATA[<p>The deflate output filter in Apache breaks Apache&#8217;s handling of the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.3">HTTP cache validation model</a>.  It won&#8217;t send an HTTP 304 status if mod_deflate is actively filtering the response, even if the Etag and Last-Modified allow it to.  I <a href="http://permalink.gmane.org/gmane.comp.apache.user/77853">asked</a>, and <a href="http://permalink.gmane.org/gmane.comp.apache.user/77854">apparently</a> this is a <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=45023">known issue</a>.  I might have to wait until after exams before making a patch for this one.</p>
<p>In its current state, this introduces a tradeoff for large, uncompressed static files (like CSS and Javascript):</p>
<ul>
<li>gzip stuff, and you improve site performance the first time someone visits, but it never gets any faster.</li>
<li>allow Apache to send 304 statuses, let the user have a slow load on their first visit, but celebrate as they hit their cache thereafter</li>
</ul>
<p>The second option looks more attractive.</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2008/apache-304s-and-mod_deflate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
