<?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>byte bohemian &#187; HTTP</title>
	<atom:link href="http://nicl.net/category/technology/http/feed/" rel="self" type="application/rss+xml" />
	<link>http://nicl.net</link>
	<description></description>
	<lastBuildDate>Sat, 15 May 2010 20:51:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating dynamic PDF, or another reason to like Apache Tapestry</title>
		<link>http://nicl.net/2009/08/creating-dynamic-pdf-or-another-reason-to-like-apache-tapestry/</link>
		<comments>http://nicl.net/2009/08/creating-dynamic-pdf-or-another-reason-to-like-apache-tapestry/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 20:40:29 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Tapestry]]></category>
		<category><![CDATA[The Flying Saucer Project]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=45</guid>
		<description><![CDATA[I am using Apache Tapestry 5 on my job since February of this year. Today was another of these days when I am pretty sure why it is a good idea to use this framework.
Last week we started the new sprint for the scoyo feature release which will be release on end of September. A [...]]]></description>
			<content:encoded><![CDATA[<p>I am using <a href="http://tapestry.apache.org/">Apache Tapestry 5</a> on my job since February of this year. Today was another of these days when I am pretty sure why it is a good idea to use this framework.<br />
<span id="more-45"></span>Last week we started the new sprint for the <a href="http://www-de.scoyo.com">scoyo</a> feature release which will be release on end of September. A website feature may require the dynamic creation of PDF files so I evaluated the possibilities of the <a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer Project"</a>, a XML/XHTML/CSS 2.1 rendering engine.</p>
<p>I already made some experiences with the <a href="https://xhtmlrenderer.dev.java.net/">Flying Saucer</a> on another job and it is still a very nice framework for PDF creation. For me, a major advantage of <a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer"</a> over other PDF creation frameworks, like XSLT and <a href="http://xmlgraphics.apache.org/fop/">FOP</a>, in the Web world is the homogenous technology mix.</p>
<p><a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer Project"</a> create PDF from XML/XHTML pages using CSS style sheets. All technologies known to the web designer that gives your web site this pretty look. I guess it's okay when you say, that XSLT and <a href="http://xmlgraphics.apache.org/fop/">FOP</a> is the more powerful technology mix, but styling pages on this technology mix is not a simple task to do.</p>
<p>So back to the initial topic: A basic ingredient which is needed to create PDFs with the <a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer Project"</a> is some XHTML. In our project at <a href="http://www-de.scoyo.com">scoyo</a> we wanted to use <a href="http://tapestry.apache.org/">Apache Tapestry</a> to create this XHTML.</p>
<p>After taking a closer look to the <a href="http://tapestry.apache.org/">Apache Tapestry</a> rendering pipeline I found out, that the <code>PageResponseRenderer</code> is the perfect place to hook up the PDF creation into the rendering process. On the one hand the <code>PageResponseRenderer</code> uses a <code>MarkupWriter</code> to create the (X)HTML content from the current <code>Page</code> instance. On the other hand the <code>PageResponseRenderer</code> is responsible for writing the generated content into the server response.</p>
<p>Using the <a href="http://tapestry.apache.org/">Apache Tapestry</a> own IoC mechanism it's quite an easy task to decorate the <a href="http://tapestry.apache.org/">Tapestry</a>  <code>PageResponseRenderer</code> implementation. It's a beautiful mechanism when you understood how it works. Okay I guess using the 5.1 version of tapestry it would be better to advice the <code>renderPageResponse(...)</code> method, but I had not enough time to get familiar with it yet.</p>
<p>One real big plus on <a href="http://tapestry.apache.org/">Apache Tapestry</a> is the implementation. Every function is well encapsulated into separate services. And the service implementing classes are very short and almost always on consistent level of abstraction. So you easily understand how a service works and you are able to copy and extend the service functions. So I extended <code>PageResponseRenderer</code> to determine if a page creates XHTML output which should be transformed to PDF. If no PDF should be created my <code>PageResponseRenderer</code> simply delegates to the original Tapestry instance.</p>
<p>When the page wants to create PDF my <code>PageResponseRenderer</code> buffers the created content and redirects it into the <code>ITextRenderer</code> of the a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer". Okay this sounds more nice, than it actually is. The content is stored into a <code>ByteArrayOutputStream</code> and re-parsed by the standard JDK XML parser for further processing by the <code>ITextRenderer</code>. But I guess the we will live with the performance impact until it gets a real issue.</p>
<p>So long explanation short story. The whole thing worked out great! It took me like two to three hours to implement a first prototype. In out web application. This also includes the embedding of custom fonts into the PDF and a nice discovery of pages to render into PDF, via custom annotations using the component model meta-data facilities and a <code>ClassTransformationWorker</code>.</p>
<p>Web development can be so easy when you are using <a href="http://tapestry.apache.org/">Apache Tapestry</a>. On an earlier project we used a similar architacture with JSP and the <a href="https://xhtmlrenderer.dev.java.net/">"The Flying Saucer"</a>. I guess it took us ten times the effort to establish an equal infrastructure using JSF and the Java Servlet API ...</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/08/creating-dynamic-pdf-or-another-reason-to-like-apache-tapestry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Excited about Tapestry 5.1</title>
		<link>http://nicl.net/2009/01/excited-about-tapestry-51/</link>
		<comments>http://nicl.net/2009/01/excited-about-tapestry-51/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 21:40:16 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Tapestry]]></category>
		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://nicl.net/2009/01/11/excited-about-tapestry-51/</guid>
		<description><![CDATA[One of the blogs I am reading on a regular basis is the Tapestry Central blog from Howard Lewis Ship the founder and lead developer of the Tapestry framework. It alreaded provided some really nice ideas and introduced me into some really interesting topics.
So this weekend I read the article about some new Features of [...]]]></description>
			<content:encoded><![CDATA[<p>One of the blogs I am reading on a regular basis is the <a href="http://tapestryjava.blogspot.com/">Tapestry Central blog</a> from <a href="http://www.blogger.com/profile/04486596490758986709">Howard Lewis Ship</a> the founder and lead developer of the <a href="http://tapestry.apache.org/">Tapestry</a> framework. It alreaded provided some really nice ideas and introduced me into some really interesting topics.</p>
<p>So this weekend I read the article about some new Features of the 5.1 Version of the <a href="http://tapestry.apache.org/">Tapestry</a> framework ...<br />
<span id="more-17"></span><br />
One of the blogs I am reading on a regular basis is the <a href="http://tapestryjava.blogspot.com/">Tapestry Central blog</a> from <a href="http://www.blogger.com/profile/04486596490758986709">Howard Lewis Ship</a> the founder and lead developer of the <a href="http://tapestry.apache.org/">Tapestry</a> framework. It already provided some really nice ideas and introduced me into some really interesting topics.</p>
<p>So this weekend I read the article about some new Features of the 5.1 Version of the <a href="http://tapestry.apache.org/">Tapestry</a> framework. And I was really exited to read about the plans to reduce/minimize the traffic over the wire. I am studying this topic for quite a while, since I stumbled across it during a project. The trigger was the <a href="http://developer.yahoo.com/performance/rules.html">Best practices article</a> from the Yahoo developer team.</p>
<p>Since then I was using different approaches and tools to improve the performance of the websites of my clients. One very useful tool is <a href="https://jawr.dev.java.net/">JAWR</a> a Javascript and CSS bundling and compression tool. <a href="https://jawr.dev.java.net/">JAWR</a> offers facilities to join multiple Javascript or CSS files in bundles. Each bundle will be delivered compressed (if possible), in addition very strong cache HTTP headers will be set to the HTTP response, so that the internet infrastructure may cache these files. So the traffic the originating server will be reduced. To prevent nasty caching problems the <a href="https://jawr.dev.java.net/">JAWR</a> framework provides facilities to generate URLs to these bundles which contain a version information, so when the bundle changes, a new URL will be generated.</p>
<p>The very exciting thing about the planned Features in <a href="http://tapestry.apache.org/">Tapestry</a> 5.1 is, that Tapestry is the first content generating web framework which will provide out the box facilities for this kind of issues.<br />
A great weakness of the JSP and JSF approaches to generate content is, that there is no fast/cheap way to determine a last modified date for a page or a component. So the application can't use the "If-Modified-Since" and "Not Modified" (HTTP status 304) mechanism to provide a lightweight answer for requested resources which have not changed. Maybe <a href="http://www.blogger.com/profile/04486596490758986709">Howard Lewis Ship</a> is able to provide this with his <a href="http://tapestry.apache.org/">Tapestry</a> framework. This would be a great performance boost for any kind of web application.</p>
<p>May very dynamic application don't address the content delivery issues at all. Its quite sad to see, but on the other hand side it's good to see that some frameworks are beginning to address this kind of features.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/01/excited-about-tapestry-51/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tomcat 6.x &#8230; doing it the right way!</title>
		<link>http://nicl.net/2008/07/tomcat-6x-doing-it-the-right-way/</link>
		<comments>http://nicl.net/2008/07/tomcat-6x-doing-it-the-right-way/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 14:24:10 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[Webserver]]></category>

		<guid isPermaLink="false">http://nicl.net/2008/07/19/tomcat-6x-doing-it-the-right-way/</guid>
		<description><![CDATA[Some days ago I posted a blog entry about using Glassfish v2 EJBs with the Tomcat. At this moment I thought that I solved the problems, but last week we were setting our testing evironment on a Debian Linux box and the problems reoccured.
At this moment I thought of a glitch in the server setup [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago I posted a blog entry about using Glassfish v2 EJBs with the Tomcat. At this moment I thought that I solved the problems, but last week we were setting our testing evironment on a Debian Linux box and the problems reoccured.</p>
<p>At this moment I thought of a glitch in the server setup but some nagging hours later I realized that my so clever solution was a dirty hack. Which works in a Microsoft Windows environment, but refuses to work on in a Linux environment.<br />
Ok,  I have to confess, that I wasn't really happy with my first solution in the end. Renaming JARs to provide the correct order of class loading always leaves a bad taste. But at that moment I was happy, no other solution was in sight and I had absolutly no time.</p>
<p><span id="more-12"></span></p>
<p>Some days ago I posted a blog entry about using Glassfish v2 EJBs with the Tomcat. At this moment I thought that I solved the problems, but last week we were setting our testing evironment on a Debian Linux box and the problems reoccured.</p>
<p>At this moment I thought of a glitch in the server setup but some nagging hours later I realized that my so clever solution was a dirty hack. Which works in a Microsoft Windows environment, but refuses to work on in a Linux environment.<br />
Ok,  I have to confess, that I wasn't really happy with my first solution in the end. Renaming JARs to provide the correct order of class loading always leaves a bad taste. But at that moment I was happy, no other solution was in sight and I had absolutly no time.</p>
<p>Enough with apologies at this moment, we were late setting up the testing environment too and there was work to do. So I decided to take a different approach and tried to find out some more about the classloading of Tomcat 6. One of my primary questions was: "Why did the Tomcat 6 developers removed the different classloading directories?"</p>
<p>The answer suprised me more, than I expected! After using Google for a while, trying to find out more about the differences in classloading between Tomcat 5.5 and Tomcat 6, I stumbled across a small file: The <code>catalina.properties</code>. This file revealed the secrets of the differnces in classloading between these two Tomcat version. The simple and quite beautyful answer is: There aren't any real differences. The distributions have different default settings, but the classloading mechanism is quite the same. At this point I am getting some more cautious than the last time. The two mechanisms are the same, as far I can judge it from my appication developer/deployer point of view <img src='http://nicl.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>So what is this <code>catalina.properties</code> all about? The <code>catalina.properties</code> - as I understand it - controls some major classloading and security issues while bootstrapping the Tomcat web container. It has three (for my problem) relevant entries:</p>
<pre>
common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar
[...]
server.loader=
[...]
shared.loader=
</pre>
<p>These three entries are controlling three classloader in Tomcats classloader hierachy. The server classloader, the common classloader and the shared classloader. The server classloader is resopnsible for loading the libraries of the tomcat server. It is not set in the Tomcat 6 default distribution and will default to the common classloader which will load the server related classes now. The common classloader is responsible for loading classes common to the tomcat installation. Which are in the Tomcat 6 the server classes as well as addiontional classes like the JavaMail API oder some database driver classes (if you are configuring them with JNDI i.e.). The last classloader is the shared classloader which may load classes which may be shared between different web applications. This is the place where the Amis <a href="http://technology.amis.nl/blog/?p=1368">blog entry</a> suggests the glassfish JARs to be placed, but which I hadn't found in the Tomcat 6 distribution.</p>
<p>After I discovered the secrets of the <code>catalina.properties</code> it took me half an hour to create a <code>shared/lib</code> directory in my <code>TOMCAT_BASE</code> and adapting the <code>catalina.properties</code> file. Now I had the proper place for my Glassfish files and it worked nearly instantly. Good to know that you can make the integration of Glassfish EJB and the Tomcat 6 in a proper way and also good to know about this tiny little classloading tricks of the Tomcat 6 <img src='http://nicl.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>As you say in german: "Kaum macht man es richtig, dann geht's!" (If you starting to do it the right way it works)</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2008/07/tomcat-6x-doing-it-the-right-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Still messing around with &#8220;ETag&#8221; and &#8220;Last-Modified&#8221;</title>
		<link>http://nicl.net/2008/05/still-messing-around-with-etag-and-last-modified/</link>
		<comments>http://nicl.net/2008/05/still-messing-around-with-etag-and-last-modified/#comments</comments>
		<pubDate>Thu, 22 May 2008 19:15:50 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://nicl.net/2008/05/22/still-messing-around-with-etag-and-last-modified/</guid>
		<description><![CDATA[Stating with this whole website performance an ETag topic opened pandoras box. It's a real mess and lame compromises all over the place. But I have to admit that the whole thing is not as easy as I expected it to be.
Anyway ... today I had a nice discussion with a colleague about this topic. [...]]]></description>
			<content:encoded><![CDATA[<p>Stating with this whole website performance an ETag topic opened pandoras box. It's a real mess and lame compromises all over the place. But I have to admit that the whole thing is not as easy as I expected it to be.</p>
<p>Anyway ... today I had a nice discussion with a colleague about this topic. He's a senior front-end developer. This means he is a real pro in HTML, CSS, Java-Script and stuff like this and he's the one who showed me the whole <a href="http://developer.yahoo.com/performance" target="_blank">Yahoo! performance stuff</a>. After this discussion I wanted to check some things out in detail.</p>
<p><span id="more-8"></span></p>
<p>Stating with this whole website performance an ETag topic opened pandoras box. It's a real mess and lame compromises all over the place. But I have to admit that the whole thing is not as easy as I expected it to be.</p>
<p>Anyway ... today I had a nice discussion with a colleague about this topic. He's a senior front-end developer. This means he is a real pro in HTML, CSS, Java-Script and stuff like this and he's the one who showed me the whole <a href="http://developer.yahoo.com/performance" target="_blank">Yahoo! performance stuff</a>. After this discussion I wanted to check some things out in detail.</p>
<p>First I wanted to check if the Apache was sending two different ETags if you have to Apache web servers delivering the content of a website. A simple test with <code>wget</code> verified it:</p>
<pre>
wget --no-dns-cache -S http://www.a-domain.de/flash/ballons_main.swf
--09:14:26--  http://www.a-domain.de/flash/ballons_main.swf
           => `ballons_main.swf'
Resolving www.a-domain.de... 84.xxx.xxx.x17, 84.xxx.xxx.x33
Connecting to www.a-domain.de|84.xxx.xxx.x17|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Date: Thu, 22 May 2008 07:14:26 GMT
  Last-Modified: Tue, 20 May 2008 15:49:24 GMT
  ETag: "1041e6-7b2c8-6c9fc900"
  Accept-Ranges: bytes
  Content-Length: 504520
  Keep-Alive: timeout=15, max=45
  Connection: Keep-Alive
  Content-Type: application/x-shockwave-flash
Length: 504,520 (493K) [application/x-shockwave-flash]
</pre>
<p>When requesting the first web server the ETag "1041e6-7b2c8-6c9fc900" war returned ...</p>
<pre>
wget --no-dns-cache -S http://www.a-domain.de/flash/ballons_main.swf
--09:14:26--  http://www.a-domain.de/flash/ballons_main.swf
           => `ballons_main.swf'
Resolving www.a-domain.de... 84.xxx.xxx.x17, 84.xxx.xxx.x33
Connecting to www.a-domain.de|84.xxx.xxx.x33|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Date: Thu, 22 May 2008 07:14:26 GMT
  Last-Modified: Tue, 20 May 2008 15:49:24 GMT
  ETag: "b824e-7b2c8-6c9fc900"
  Accept-Ranges: bytes
  Content-Length: 504520
  Keep-Alive: timeout=15, max=45
  Connection: Keep-Alive
  Content-Type: application/x-shockwave-flash
Length: 504,520 (493K) [application/x-shockwave-flash]
</pre>
<p>... after requesting the second web server the ETag "b824e-7b2c8-6c9fc900". So if you do not disable the INode usage for the ETag calculation the whole mechanism will not work. But does this really matter. As you can see the DNS caching was disabled for the test. In a real life situation the DNS caching we be activated and my browser will talk only to one web server and the INode issue won't matter at all.<br />
But if we have multiple web server and the internet browser will only talk to one of them, why do I need the ETag? The Last-Modified header will be enough, won't it?</p>
<p>So my conclusion is use either the Last-Modifed header or the ETag header but using both header makes no really sense at all. This should be right in any case for the Apache HTTPD, the Microsoft IIS or any other web server delivering static content. I also recommend using the Last-Modified because the ETag calculation requires more computing time. There is only one scenario I can provide where the ETag will work and the Last-Modifed Header will not. If someone is changing content and does not modify the last modified time stamp. But this should be rather uncommon.</p>
<p>But how is the situation at dynamic content creation? My favorite web framework is Java Servlets and all related technologies (JSP, JSF, Tapestry, and so on) and after that very disappointing chapter with the ETag I decided to take a closer look at the facilities the servlet and JSP APIs are offering. Another sad very sad story at my actual point of view right now. But for tonight it is enough. Later more about it ...</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2008/05/still-messing-around-with-etag-and-last-modified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An ETag is not about aliens</title>
		<link>http://nicl.net/2008/05/an-etag-is-not-about-aliens/</link>
		<comments>http://nicl.net/2008/05/an-etag-is-not-about-aliens/#comments</comments>
		<pubDate>Sun, 18 May 2008 18:27:26 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Servlet]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Webserver]]></category>

		<guid isPermaLink="false">http://nicl.net/2008/05/18/an-etag-is-not-about-aliens/</guid>
		<description><![CDATA[So what is this ETag thing. I am working since 1998 in the web business but I came across ETags some weeks ago when some of my customers starting to worry about their perfomace. Don't get me wrong, out apllication worked - as always - fine, but some pages where slower as the equivalent pages [...]]]></description>
			<content:encoded><![CDATA[<p>So what is this ETag thing. I am working since 1998 in the web business but I came across ETags some weeks ago when some of my customers starting to worry about their perfomace. Don't get me wrong, out apllication worked - as always - fine, but some pages where slower as the equivalent pages at the websites of their competitors. We checked our monitoring data, it's always good to know of the webstite performed on yesterday, yesterweek or yestermonth, but were unable to find some issues. So we went from the server to the protocol and the client and checked some static and dynamic pages. As I was taking a closer look at a static webpage I stumbled over a HTTP header which I didn't know: ETag.<br />
<span id="more-5"></span></p>
<p>So well, my first blog post with some contentent. I am quite excited and somewhat terrified, I really hope my english will be good enough.</p>
<p>
<p>So what is this ETag thing. I am working since 1998 in the web business but I came across ETags some weeks ago when some of my customers starting to worry about their perfomace. Don't get me wrong, out apllication worked - as always - fine, but some pages where slower as the equivalent pages at the websites of their competitors. We checked our monitoring data, it's always good to know of the webstite performed on yesterday, yesterweek or yestermonth, but were unable to find some issues. So we went from the server to the protocol and the client and checked some static and dynamic pages. As I was taking a closer look at a static webpage I stumbled over a HTTP header which I didn't know: ETag.</p>
<p>
<p>What is this ETag thingy? Why do only static pages have it? Okay to get this clear, I have to reveal some secrets about our customers setup. It runs on an Apache webserver who delegates the dynamic webpages to a Tomcat servlet container. They dynamic content will be generated there by some servlets and JSP. But this is also the solution. The static page was deliviered by the Apache HTTPD and the server adds the ETag header to all files.</p>
<p>
<p>So again what is this ETag thingy? What is it good for? Something I learned some years ago: It's always a good Idea to go to the source. In this case its the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19">RFC 2616</a> in Section 14.19 the ETag HTTP header field is defined. But nowadays it's quite okay if you check Wikipedia first and at least a Wikipedia you will get a link to the RFC.</p>
<p>
<p>I confess it took a little while for me to understand what the ETag is good for. The web server may create an entity tag for the requested entity. This tag acts like some kind of content identifier or a kind of version number of the content. The Browser can use this information at a later time, when the entity (URL) is requested again send the ETag value in the "<span style=" ;font-family:Helvetica;font-size:12px;">If-Match" or more likely the "If-None-Match" header field. If the browser does so, the server may evaluate the header and send a simple 304 (Not Modified) response instead of a 200 (OK) response and the data of the entity. The whole thing works basically equally to the "Last-Modified" and "If-Modified-Since" or "If-Unmodified-Since" mechanism. So why to we need this redundancy?</span></p>
<p>
<p>I am not that deep into the specification process of the HTTP protocol, but I am working a while with distrubuted web applications. Sometimes you simply need to mess around with the latest modification date of a file to get some rsync-ing right or something like that. In general the bad news is: The last modified date is not that reliable if you want to determine if a file is still the same. So this ETag thingy seems to be a good solution to this.</p>
<p>
<p>In real life nothing is this easy. The Apache web server calculates the ETag value out of the INode of the file, the last modified date and the size of the file. This is quite awkward if you have more than one HTTPD instance delivering the same file (i.e. if you use DNS round robin load balancing). It would be a small miracle if the file gets an INode with the same id on the different instances. So the ETag mechanism may get some kind of useless, so that Yahoo! recommends in their <a href="http://developer.yahoo.com/performance/rules.html">Best Practices for Speeding Up Your Web Site</a> to deactivate the mechanism. The logic behind this recommendation is: A useless check done is a waste of time. I am not totally lucky with this but Yahoo! has some kind of point with it.</p>
<p>
<p>Luckily you can configure the ETag creation in the Apache web server with the <a href="http://httpd.apache.org/docs/2.2/mod/core.html#fileetag">FileETag</a> directive. So may use only the modification time (MTime) and the file size (Size) for the ETag creation. This should work out quite well and if you can keep the last modified date in sync between the your web server instances the mechanism should work properly.</p>
<p>
<p>Okay I hope someone else reads this and may find it useful. At the moment I am investigating some ETag and last modified header issues with servlets and JSP. I guess I will try to blog about it soon ...</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2008/05/an-etag-is-not-about-aliens/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
