From: Amos Jeffries Date: Wed, 20 Oct 2010 06:14:09 +0000 (-0600) Subject: Author: Alex Rousskov X-Git-Tag: SQUID_3_1_9~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8d826e50cc7adc75081fc06a27320bc7e4af669;p=thirdparty%2Fsquid.git Author: Alex Rousskov HTTP Compliance: improve age calculation. Account for response delay in age calculation as described in RFC 2616 section 13.2.3. Co-Advisor test cases: test_case/rfc2616/ageCalc-none-7-none test_case/rfc2616/ageCalc-5400-4-5 --- diff --git a/src/store.cc b/src/store.cc index fe3b846681..ca877eae5e 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1486,14 +1486,7 @@ StoreEntry::timestampsSet() const HttpReply *reply = getReply(); time_t served_date = reply->date; int age = reply->header.getInt(HDR_AGE); - /* - * The timestamp calculations below tries to mimic the properties - * of the age calculation in RFC2616 section 13.2.3. The implementaion - * isn't complete, and the most notable exception from the RFC is that - * this does not account for response_delay, but it probably does - * not matter much as this is calculated immediately when the headers - * are received, not when the whole response has been received. - */ + /* Compute the timestamp, mimicking RFC2616 section 13.2.3. */ /* make sure that 0 <= served_date <= squid_curtime */ if (served_date < 0 || served_date > squid_curtime) @@ -1509,6 +1502,14 @@ StoreEntry::timestampsSet() if (squid_curtime > age) served_date = squid_curtime - age; + // compensate for Squid-to-server and server-to-Squid delays + if (mem_obj && mem_obj->request) { + const time_t request_sent = + mem_obj->request->hier.peer_http_request_sent.tv_sec; + if (0 < request_sent && request_sent < squid_curtime) + served_date -= (squid_curtime - request_sent); + } + if (reply->expires > 0 && reply->date > -1) expires = served_date + (reply->expires - reply->date); else