cached HTTPResource attributes

Jason Hoos writes:
 > I'm looking through the HTTPResource class right now, and I've noticed that 
 > there are several variables for cached copies of attributes such as 
 > "contenttype", "contenetlength", "lastmodified", and several others.  It 
 > appears that these are updated by calling updateCachedHeaders(), and are set to 
 > null if they are outdated by setValue().  Supposedly this is provided so that 
 > these values can be accessed quickly without going through the attributes. 
 > 
 > My question is, why don't the various getContentType(), getContentLength(), 
 > etc. methods of HTTPResource actually use any of them?

Your initial assumption is not exactly true. The updateCachedHeaders
duty is to update cached header values. HTTP header values are
expensive to generate (they all involve a transformation of some piece
of data into a String). Cached header values try to avoid recomputing
this transformation each time.

Attribute holds tha value in its "native" format (eg ContentLength is
an int). Cached header values cache values in their HTTP wrapper (so,
for example, the content length is stringified only once).

Hope this helps,
Anselm.

Received on Monday, 25 November 1996 04:39:47 UTC