Re: Confusion about Age: accuracy vs. safety

Koen Holtman writes:
 > Jeffrey Mogul:
 > >To wit: the spec
 > >explicitly allows your caches to ignore the expiration times 
 > 
 > This is only allowed if a Warning is added, I believe.
 > 
 > I have always had doubts about whether cache implementers would want
 > to implement Jeff's Age calculation algorithm without any changes.

I can speak for myself here: as I am not as wise as you guys, and as I
don't have much time for discussions, I did implement *exactly* (as
faithfully as possible - see code below), Jeff's pseudo code.

Anselm.
BTW: if you find a bug in this code, let me know !

    public void updateAges(Request request, Reply reply) {
	// Quickly save the reponse time:
	long response_time = System.currentTimeMillis();
	setResponseTime(response_time);
	// HTTP/1.1, Section 13.2.3, Age Calculation
	long age_value     = reply.getAge();
	long date_value    = reply.getDate();
	long request_time  = request.getDate();
	
	long apparent_age   = Math.max(0, response_time-date_value);
	long c_received_age = Math.max(apparent_age, age_value);
	long response_delay = response_time - request_time;
	// Save the initial age:
	setInitialAge(c_received_age + response_delay);
	// Save the date of the reply:
	if ( date_value > 0 )
	    setDate(date_value);
	// Look for HTTP/1.1 specific headers:
	if ( reply.getMajorVersion() >= 1 ) {
	    // HTTP/1.x specific headers: maxage
	    long maxage = ((long) reply.getMaxAge()) * 1000;
	    if ((maxage < 0) &&  reply.hasHeader(reply.H_EXPIRES) ) 
		maxage = reply.getExpires() - reply.getDate() ;
	    if ( maxage >= 0 )
		setMaxAge(maxage);
	    else
		setDefaultMaxAge();
	    // HTTP/1.1 specific headers: *-revalidate
	    if ( reply.getMinorVersion() >= 1 ) {
		setRevalidate(false);
		if ( reply.checkMustRevalidate() )
		    setRevalidate(true);
		if ( ( ! isShared()) && reply.checkProxyRevalidate() )
		    setRevalidate(true);
	    }
	}
    }

Received on Wednesday, 4 September 1996 06:47:50 UTC