Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 11055 invoked from network); 4 Sep 2008 10:47:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Sep 2008 10:47:12 -0000 Received: (qmail 94998 invoked by uid 500); 4 Sep 2008 10:46:54 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 94118 invoked by uid 500); 4 Sep 2008 10:46:50 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 94107 invoked by uid 99); 4 Sep 2008 10:46:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Sep 2008 03:46:50 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of valotas@gmail.com designates 72.14.204.174 as permitted sender) Received: from [72.14.204.174] (HELO qb-out-1314.google.com) (72.14.204.174) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Sep 2008 10:45:49 +0000 Received: by qb-out-1314.google.com with SMTP id p4so4375284qba.40 for ; Thu, 04 Sep 2008 03:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=xSIBHc6kQIYQKKo1z5PleE4YkepV/UaWPNCQTKLm3FI=; b=UTa9HmHjlMmn67DwBkq/vptX9/bTT8LlNqvMdfN1TT/xeazbEZZ63Mwz6sjj228Vnj AtlpKZrg190Q0gGUEvx4CsmUEceUdZXsuddkmNop3mfGqdQ0sagI9A4rGaLLWVIfn8Mf jyKacA+sBMKijVL7vdo4OyxaC/64ndt9nwPwU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=jDxRNN7oTJS7ZbLPbXRTVxyoWjVumz3NI0aJs+W0Jjf9LX9dlOnobj7/mlEE7ggVJO Dk1CsQVQQxy3VIlu7G5v0eX6DyOn7KzBGgI23Qlg6V6wgsiKgZt13lJdu5/MoNdd9AE+ JagNRavVVE/Mq15Ax6YvVauO/3ZdoxYKAUkzo= Received: by 10.115.89.1 with SMTP id r1mr8642254wal.12.1220525169496; Thu, 04 Sep 2008 03:46:09 -0700 (PDT) Received: by 10.115.93.7 with HTTP; Thu, 4 Sep 2008 03:46:09 -0700 (PDT) Message-ID: <17ee3b690809040346ob28df54m88ad9498925b2e14@mail.gmail.com> Date: Thu, 4 Sep 2008 13:46:09 +0300 From: Yoryos To: "Tomcat Users List" Subject: Re: Etags vs Week Etags In-Reply-To: <00ae01c90e76$14963d50$0300000a@animal> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_40081_17087391.1220525169498" References: <002901c90e01$0178a610$0300000a@animal> <17ee3b690809040008u4c44713fl82736a82b2ec14e3@mail.gmail.com> <00ae01c90e76$14963d50$0300000a@animal> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_40081_17087391.1220525169498 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Thu, Sep 4, 2008 at 1:07 PM, Johnny Kewl wrote: > > ----- Original Message ----- From: "Yoryos" > To: "Tomcat Users List" > Sent: Thursday, September 04, 2008 9:08 AM > > Subject: Re: Etags vs Week Etags > > > On Wed, Sep 3, 2008 at 11:09 PM, Johnny Kewl >> wrote: >> >> >>> ----- Original Message ----- From: "Johnny Kewl" >>> To: "Tomcat Users List" >>> Sent: Wednesday, September 03, 2008 9:51 PM >>> >>> Subject: Re: Etags vs Week Etags >>> >>> >>> >>> ----- Original Message ----- From: "Yoryos" >>>> To: "Tomcat Users List" >>>> Sent: Wednesday, September 03, 2008 8:57 PM >>>> Subject: Re: Etags vs Week Etags >>>> >>>> >>>> On Wed, Sep 3, 2008 at 8:12 PM, Johnny Kewl >>>> >>>>> 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 can anyone also explain to me the first if block of code here: >> >> public String getETag(boolean strong) { >> String result = null; >> if (attributes != null) { >> Attribute attribute = attributes.get(ETAG); >> if (attribute != null) { >> try { >> result = attribute.get().toString(); >> } catch (NamingException e) { >> ; // No value for the attribute >> } >> } >> } >> if (strong) { >> // The strong ETag must always be calculated by the resources >> result = strongETag; >> } else { >> // The weakETag is contentLenght + lastModified >> if (weakETag == null) { >> weakETag = "W/\"" + getContentLength() + "-" >> + getLastModified() + "\""; >> } >> result = weakETag; >> } >> return result; >> } >> >> >> I think it is not realy needed! >> > > Yory, I'm tired pulling long hours on something, so please check me ;) > > Yes, not needed, its another hook... coder has left it there in case he > needs it... > In theory, when I look at the code, all you really have to do is > setEtag.... and that will be used. > If you leave the W/\"" off... its a strong tag.... > > or if you > if (strong) > weakETag = getContentLength() + "-" + getLastModified() + > "\""; > > I think you done... TC will now do strong tags > > To understand whats going on with that stuff... attributes is a bunch of > collections. > They way its being used is when you drop a static resource into tomcat > theres a war engine somewhere that detects it... > When that happens... they stick things in there like ContentLength and > LastModified... ie the file attributes... > And then they use the collections to compute the eTag... > That getContentLength() function is also using those "memory" of > attributes... > > Its a hash map so you can add whatever you need to it.... thus he has left > the hook in there... > > Then things like > checkIfNoneMatch and all the rest should be in the default servlet... and > they will all call into the above, so if your > etag is there... thats going to be used... > > In that link ( the clever guy link) all he is doing is getting at the > setETag function... which comes back as > strongETag > and he is getting the stuff out of the collections so that > he doenst have to recheck the static resource last mod time etc... but > equally he could have added something... and then the hook gets useful... > > It does look unfinished, but this ETag stuff is difficult... say for > example you have a JSP file and that includes other JSP files... how would > you code that so that humble users can do it.... probably end up just > leaving a hook in there as well, for high IQ systems ;) > > Remy Maucherat is the default servlet guy... hopefully he can confirm > > Have fun... > Thanks for the answer! As I've seen tomcat does not ad the etag header to jsps and other servlets. That should be the work of the programmer of the servlet. The only thing it does is addind this header to the static content. The solution of the clever guy does not seem to work! At least not in tomcat 6 (that I am using, but didn't test it on 5). As I've seen tomcat let's you define an implementation of the context it can use. The only problem is that FileDirContext witch overides this clever guy does not implement all the interfaces it should in order to "work" as a context. Form the other side StandardContext witch should be extended in order to get something working does some casting to FileDirContext depending the request. Anyway I'll try to find a "portable" solution as I wouldn't like to hack the source of the tomcat in order to have strong etags. Thank you for your help and time! ------=_Part_40081_17087391.1220525169498--