Re: Etags vs Week Etags
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Johnny, Johnny Kewl wrote: For example if you want XSLT in tomcat, first impression is its xerces and a complex servlet and lots of pain... you actually think tomcat cant do it, but then you look at the default servlet and Obama! its there ;) I call it TC's hidden gold mine ;) Huh? The DefaultServlet handles XSLT? Which version of TC is that in? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkjJLQUACgkQ9CaO5/Lv0PCsMACePMBUKaiBBNSa4Pas1rAWHMrs +AMAniYceggtNMymZBnKe28WfKaTt8vc =6X5C -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Etags vs Week Etags
On Sep 11, 2008, at 10:36 AM, Christopher Schultz wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Johnny, Johnny Kewl wrote: For example if you want XSLT in tomcat, first impression is its xerces (Jumping without reading previous posts) You first impression is wrong :) Xerces is an XML parser. Xalan (and better, Saxon) is an XSL processor. Xalan is built into the JDK, so you get that by default unless you change the JAXP system property. and a complex servlet and lots of pain... you actually think tomcat cant do it, but then you look at the default servlet and Obama! its there ;) I call it TC's hidden gold mine ;) Saxon (preferably v 9x, so XSL 2.0) has a nice, simple servlet example for XSL/XML transformations. (On another thread in this list, someone was talking about disabling everything but taglibs in JSP. Well, if you used well-formed JSP, you could stick an XSL filter before the JSP and use an identity transform to strip out the things you don't want.) Huh? The DefaultServlet handles XSLT? Which version of TC is that in? There is XSL for directory listings by default. best, -Rob - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Etags vs Week Etags
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Robert, Robert Koberg wrote: On Sep 11, 2008, at 10:36 AM, Christopher Schultz wrote: Huh? The DefaultServlet handles XSLT? Which version of TC is that in? There is XSL for directory listings by default. Okay, that makes WAY more sense. Otherwise, I've been wasting a /lot/ of time with Cocoon! ;) (Just kidding, Cocoon totally rocks) - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkjJPM4ACgkQ9CaO5/Lv0PCgOACgsQqurWAYbuGIEKumqK7PjryZ Zp0An2w6302qRonjzi1ICYJLeVSNjZfL =Wsrj -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Etags vs Week Etags
On Sep 11, 2008, at 11:44 AM, Christopher Schultz wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Robert, Robert Koberg wrote: On Sep 11, 2008, at 10:36 AM, Christopher Schultz wrote: Huh? The DefaultServlet handles XSLT? Which version of TC is that in? There is XSL for directory listings by default. Okay, that makes WAY more sense. Otherwise, I've been wasting a / lot/ of time with Cocoon! ;) Otherwise? :) - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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!
Re: Etags vs Week Etags
- 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
Re: Etags vs Week Etags
On Thu, Sep 4, 2008 at 1:07 PM, Johnny Kewl [EMAIL PROTECTED] wrote: - 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
Re: Etags vs Week Etags
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! Yory, had some sleep... ha ha Yes you right... actually meant to say jsp files that include html files... Anyway, listen before you give up on this, drop me a email because its something that I'm interested in... You see that (now not so clever guy) is aiming at the default servlet... but this technology is also the basis of super RSS type stuff... thats my interest. Thats why I think it has to be done in a frontend servlet... For example... default will pick up on changes in images htm etc... but what happens when you have a JSP that pulls 500k from a dB... If you wanted to make that efficient... then the JSP page doesnt matter, whether or not the data in the recordset changes for the same query matters... so thats what would be in the Etag and that means one could build very efficient sites. Say you have a ajax site that displays a file structure... and you only want it to send all that stuff if the section is changed... Its way beyond simple Etags... ie I think you want to be able to cover other servlets and JSP as well... Etags actually dont go much further than normal browser caching in the default servlet implementation. Let me know what it is you actually trying to do, and if it comes close to my interest in it... you'll get the code for nothing ;) regards... - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Etags vs Week Etags
Hi all, I don't know if I should be postting the the dev list but let's try from here. I'm trying to understand how the etag are being applying to the static resources. My problem is that I would like to get rid of the week etags, that tomcat is applying. After a little bit of searching I ended up to the org.apache.naming.resources.ResourceAttributes class where I found the getETag(boolean strong) method. It's a very small method but I didn't understand a small thing. Well the method is the above: 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; } And my question is what the first if condition stand's for. Even if we'll get an etag value (result = attribute.get().toString();), exatly after the first if block, we get if / else blocks witch results to overriding the previous result value to a strongETag or a weekETag! What made me trying to find what is going on is that I always get week etags for my static resources, witch is something I whould like to overcome as some browsers doesn't handle them really well. Thank you!
Re: Etags vs Week Etags
- Original Message - From: Yoryos [EMAIL PROTECTED] To: users@tomcat.apache.org Sent: Wednesday, September 03, 2008 1:14 PM Subject: Etags vs Week Etags Hi all, I don't know if I should be postting the the dev list but let's try from here. I'm trying to understand how the etag are being applying to the static resources. My problem is that I would like to get rid of the week etags, that tomcat is applying. After a little bit of searching I ended up to the org.apache.naming.resources.ResourceAttributes class where I found the getETag(boolean strong) method. It's a very small method but I didn't understand a small thing. Well the method is the above: 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; } And my question is what the first if condition stand's for. Even if we'll get an etag value (result = attribute.get().toString();), exatly after the first if block, we get if / else blocks witch results to overriding the previous result value to a strongETag or a weekETag! What made me trying to find what is going on is that I always get week etags for my static resources, witch is something I whould like to overcome as some browsers doesn't handle them really well. Thank you! 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 --- 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]
Re: Etags vs Week Etags
Suppose I need to explain what I would try... You in the code already so stealing the getLastMosified routing or whatever is easy.. If you map a servlet to say... /MyStaticStuff/*.jsp /MyStaticStuff/*.jpg That servlet will get all those requests... Then you rename your static resources that you want to control, say to jpg_myway So /MyStaticStuff/somepage.jsp will hit your selvet... Your servlet checks somepage.jsp_myway if ok... send back no change if not ok forward to jsp page and hopefully that works... Something like that --- 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]
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 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.
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 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. I would try front end servlet, or a filter before massaging default servlet... but I agree, there is a lot of functionality in that deafult servlet that could be brought out... As options and as extended tools in normal servlets. Probably has a lot to do with following Suns specs to the letter, which is a good thing I guess. For example if you want XSLT in tomcat, first impression is its xerces and a complex servlet and lots of pain... you actually think tomcat cant do it, but then you look at the default servlet and Obama! its there ;) I call it TC's hidden gold mine ;) --- 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]
Re: Etags vs Week Etags
- 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 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. I would try front end servlet, or a filter before massaging default servlet... but I agree, there is a lot of functionality in that deafult servlet that could be brought out... As options and as extended tools in normal servlets. Probably has a lot to do with following Suns specs to the letter, which is a good thing I guess. For example if you want XSLT in tomcat, first impression is its xerces and a complex servlet and lots of pain... you actually think tomcat cant do it, but then you look at the default servlet and Obama! its there ;) I call it TC's hidden gold mine ;) Actually Yoryos... if you do decide on the overload method, been there tried that, its not really designed for it, its actually easier to isolate the whole servlet... ie just steal the code and make another servlet... packaging gets a little trick but the resulting solution is very small. Thats how I fixed WebDav, which is another thing hiding in that gold mine ;) It that case its not broken, but MS broke the spec, so Java guys say MS... you fix it, and MS says, we own the planet, so go play in Georgia... what I did is make one that works with both... so probably not a bad thing getting into it anyway... lots of good stuff there ;) --- 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]