On Wed, Sep 3, 2008 at 8:12 PM, Johnny Kewl <[EMAIL PROTECTED]> wrote:

>
> Flipping good question... and I have a feeling that there is some
> philosophy in the answer... reasons for the way it done...
> The short answer is that you cant (I think)... the default servlet makes em
> weak (thats the philamamasomamy)...
> That first section (strong) does nothing... the reason is that the setEtag
> method is there but as far as i can tell, never ever called by anything in
> Tomcat.
> Its a hook...
>
> But stay calm... there are ways...
>
> This clever guy did this...
>
> http://blog.bcarlso.net/articles/2007/10/19/tomcat-weak-etags-and-javascript-css-caching
>
> He is basically overriding the default servlet stuff to get things done....
> its smart, he knows his tomcat, but personally I dont like it...
>
> I think the generic problem is that a static resource cant control its
> Etag... its a dumb image, and secondly no matter what a web server does,
> another web server is going to do it different, so strong loses its meaning
> (more philamamasomamy)... or more simply, you just got to do it yourself...
>
> I would prefer (or try, I havnt giving this a go)... make a little servlet,
> set the Etag headers yourself, map it to all the static resources you want
> to control...
> And then do what you have to
>
> getContentLength() + "-" + getLastModified() + IncludeFiles() +
> IncludedImages() + WhateEver() "\"";
>
> etc... I think thats easiest...
>
> The philamamasomamy on why TC chose to make it weak would be interesting to
> hear, but I do think that any serious scheme... on its way to some kind of
> private RSS system... will be doing its own thing.
>
> Have fun... nice question
>
>
Well a quick solution is to extend the DefaultServlet to apply a "good"
etag. But then I should also check for this etag in case I have a request
with headers If-None-Match. This means that I should also extend the
org.apache.naming.resources.ResourceAttributes
class in order to be giving me a "good" etag.
I don't really care about the philosophy of using week etags. I'm sure there
is one but as I can see there isn't any easy way of letting the user decide
the default headers of static content except from reinventing the wheel
(creating a custom DefaultServlet) and I think this is a problem as the
implementation of a new DefaultServlet isn't as easy as it seems to be.

Reply via email to