* squid-2.3.DEVEL3.age.patch * Mon Jan 3 05:44:13 CET 2000 Modified Files in squid/src store.c Corrected age calculation to take into account any existing Age header added by upstream caches. ----------------------------------------------------------------- Mon Jan 3 05:46:06 CET 2000 Modified Files in squid/src client_side.c Added a small workaround for IE browsers who hang on certain replies with a "Age: 0" header. Index: squid/src/client_side.c diff -u squid/src/client_side.c:1.1.1.46.2.7 squid/src/client_side.c:1.1.1.46.2.8 --- squid/src/client_side.c:1.1.1.46.2.7 Sat Dec 25 10:45:22 1999 +++ squid/src/client_side.c Mon Jan 3 05:46:04 2000 @@ -1180,20 +1180,29 @@ if (request->range) clientBuildRangeHeader(http, rep); /* - * Add Age header, not that our header must replace Age headers - * from other caches if any + * Add a estimated Age header on cache hits. */ - if (http->entry->timestamp > 0) { + if (is_hit) { + /* + * Remove any existing Age header sent by upstream caches + * (note that the existing header is passed along unmodified + * on cache misses) + */ httpHeaderDelById(hdr, HDR_AGE); - /* - * we do not follow HTTP/1.1 precisely here becuase we rely - * on Date header when computing entry->timestamp; we should - * be using _request_ time if Date header is not available - * or if it is out of sync + /* + * This adds the calculated object age. Note that the details of the + * age calculation is performed by adjusting the timestamp in + * storeTimestampsSet(), not here. + * + * BROWSER WORKAROUND: IE sometimes hangs when receiving a 0 Age + * header, so don't use it unless there is a age to report. Please + * note that Age is only used to make a conservative estimation of + * the objects age, so a Age: 0 header does not add any useful + * information to the reply in any case. */ - httpHeaderPutInt(hdr, HDR_AGE, - http->entry->timestamp <= squid_curtime ? - squid_curtime - http->entry->timestamp : 0); + if (http->entry->timestamp < squid_curtime) + httpHeaderPutInt(hdr, HDR_AGE, + squid_curtime - http->entry->timestamp); } /* Append X-Cache */ httpHeaderPutStrf(hdr, HDR_X_CACHE, "%s from %s", Index: squid/src/store.c diff -u squid/src/store.c:1.1.1.43.2.3 squid/src/store.c:1.1.1.43.2.4 --- squid/src/store.c:1.1.1.43.2.3 Sun Nov 21 16:19:57 1999 +++ squid/src/store.c Mon Jan 3 05:44:12 2000 @@ -1256,9 +1256,24 @@ { const HttpReply *reply = entry->mem_obj->reply; time_t served_date = reply->date; + int age = httpHeaderGetInt(&reply->header, 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. + */ /* make sure that 0 <= served_date <= squid_curtime */ if (served_date < 0 || served_date > squid_curtime) served_date = squid_curtime; + /* + * Compensate with Age header if origin server clock is ahead of us + * and there is a cache in between us and the origin server + */ + if (age > squid_curtime - served_date) + served_date = squid_curtime - age; entry->expires = reply->expires; entry->lastmod = reply->last_modified; entry->timestamp = served_date;