<?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>Technology of Content &#187; PATCH</title>
	<atom:link href="http://blog.technologyofcontent.com/tag/patch/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.technologyofcontent.com</link>
	<description>Ramblings on the technology of content management</description>
	<lastBuildDate>Sun, 29 Jan 2012 16:38:05 +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>Smart resources, or why you should care about HTTP PATCH</title>
		<link>http://blog.technologyofcontent.com/2009/12/smart-resources-or-why-you-should-care-about-http-patch/</link>
		<comments>http://blog.technologyofcontent.com/2009/12/smart-resources-or-why-you-should-care-about-http-patch/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 23:42:06 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[REST]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[PATCH]]></category>

		<guid isPermaLink="false">http://blog.technologyofcontent.com/?p=169</guid>
		<description><![CDATA[Unusually, there has been a significant change to the HTTP protocol this week. The PATCH method was approved by the IETF. This is a big change as one of the parts of the HTTP model is the small &#8220;uniform interface&#8221;, where there are very few things you can do to web resources. GET is the [...]]]></description>
			<content:encoded><![CDATA[<p>Unusually, there has been a significant change to the HTTP protocol this week. The <a href="http://greenbytes.de/tech/webdav/draft-dusseault-http-patch-16.html">PATCH method</a> was approved by the <a href="https://datatracker.ietf.org/drafts/draft-dusseault-http-patch/">IETF</a>.</p>

<p>This is a big change as one of the parts of the HTTP model is the small &#8220;uniform interface&#8221;, where there are very few things you can do to web resources. GET is the most common, to retrieve a resource representation. Then there is PUT to update a resource, and DELETE to delete it. Then there is POST, which tends to cover everything else you might want to do. The problem with that is that discovering the interface for POST is difficult, as is knowing exactly what it will do. (There are a few other verbs too).</p>

<p>PATCH is much more straightforward. PUT updates an entire resource with a new version, while PATCH just makes an amendment to a resource. For some types of resource, the entire resource may be large, so that just sending differences will save bandwidth. Also, sending the full resource may unnecessarily make the changes sequential, for example append operations where the order of the operations is not significant. One example given is a log file, where many processes  may be adding entries, and if they had to retrieve the whole log, append a new entry and write it back there would be a lot of extra traffic, and a chance of either lost updates or processes having to retry if the resource was modified during this process. Clearly a PATCH operation here that does an append would make sense. I am not sure that is actually a very good example though, as you would  almost certainly create a resource for each log entry, rather than one for the whole lot, but clearly other similar patterns exist.</p>

<h2>HTTP is not a filesystem</h2>

<p>When it was new, people tended to treat HTTP like a filesystem. After all that was the common model for storage, and web servers generally stored web pages as files, so they tended to e treated much like that, with filename extensions annd index files, and WEBDAV was created to try to make the web usable as a filesystem protocol. This model does not really work very well however, as it does not model the things you can and can&#8217;t do with HTTP. The methods are one example; updating entire resources at once means they tend to be small units, rather than, for example, log files. File systems generally struggle to store millions of tiny files without wasting a lot of space, and without becoming slower. The web  resource does not have to support full Unix filesystem semantics (a topic that oddly Wikipedia seems to be missing an entry on! May have to rectify that), and supports a much simpler updte model.</p>

<p>Maybe the easist way of thinking about HTTP is to see every URL is a small <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Model View Controller</a> (MVC) system. The model is an abstract resource, which we can see through GET, which retieves views. There can be multiple views, as a request can ask for different media types and encodings for a single resource. The controllers are the media types supported by PUT, which are usually the same as those for GET, but need not be; because both the view and the controller need to represent the whole resource state, they do tend to be quite complex representations, such as XML documents. PATCH however is also a controller, but a more interesting one in many ways, as it can send just state changes to the model, which tends to be how many MVC systems work.</p>

<p>Another thing that PATCH enables is resources that hide some of their state. A resource could only support PATCH and not PUT so that state modifications were only changes. If the state returned by GET is not the complete state, the resource could hide parts of the model. An example could be a voting method that records but does not reveal who has voted, only returning totals, which accepts votes as PATCH requests.</p>

<h2>Server side scripting</h2>

<p>One PATCH format that makes a lot of sense is actually to use executable code, rather than say diff files. There is no reason why you  should not send the server a PATCH request that is some Javascript to modify the DOM of an HTML resource which can be executed serverside, or an XSL transform to modify and XML object. Sending code is an efficient way of making changes to a resource, and can be executed in a sandbox like the browser sandbox. This will be another driving factor for Javascript on the server side, as it is well suited for embedding like this, and already has a DOM model for transforms.</p>

<p>All these changes take us further away from the filesystem model. Web resources will more and more combine some storage with some computation, including ability to execute code in a contolled way. Smart resources will become more common, over dumb storage only resources.</p>

<h2>In other news</h2>

<p>Next in line for HTTP, hopefully, is the <a href="http://tools.ietf.org/html/draft-nottingham-http-link-header-06">Link header</a> which adds a new header for legacy document formats that do not include a native hyperlinking capability. This will allow relationships between these documents to be included in the retrieved resource, such as a link to metadata or other related resources. The HTTP replacement for the file system model is getting serious.</p>

<!--a href="http://geekandpoke.typepad.com/geekandpoke/2009/11/service-calling-made-easy-part-1.htm"><img src="http://geekandpoke.typepad.com/.a/6a00d8341d3df553ef012875f312f9970c-pi" width="400"/></a-->
]]></content:encoded>
			<wfw:commentRss>http://blog.technologyofcontent.com/2009/12/smart-resources-or-why-you-should-care-about-http-patch/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Content Delivery Network via Amazon Web Services: CloudFront: blog.edge3.org

Served from: blog.technologyofcontent.com @ 2012-02-04 13:57:55 -->
