----- Original Message -----
From: "Yoryos" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
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 <[EMAIL PROTECTED]> wrote:
----- Original Message ----- From: "Johnny Kewl" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Wednesday, September 03, 2008 9:51 PM
Subject: Re: Etags vs Week Etags
----- Original Message ----- From: "Yoryos" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
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 <[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 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...
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]