These two options have been a bit of annoyance for a long time. Primarily because they are custom controls and almost all uses of them is the garbage '0' values that even MSIE ignores completely. Validating correctness would add processing which offsets the performance gained from ignoring them.
It has come to my attention that the MSIE guys are now advising people not to use them. So it seems we can take advantage and make some performance gains on a lot of traffic, while helping to hasten their demise. By adding these as registered CC values which are just dropped we can both reduce outbound bandwith by ~20 bytes per message and avoid all the slow String handling which CC_OTHER brings to the processing when these are the only non-standard options present. Amos
=== modified file 'src/HttpHdrCc.cc' --- src/HttpHdrCc.cc 2017-01-07 03:10:12 +0000 +++ src/HttpHdrCc.cc 2017-01-26 02:38:15 +0000 @@ -24,40 +24,42 @@ #include <map> #include <vector> #include <ostream> // invariant: row[j].id == j static LookupTable<HttpHdrCcType>::Record CcAttrs[] = { {"public", HttpHdrCcType::CC_PUBLIC}, {"private", HttpHdrCcType::CC_PRIVATE}, {"no-cache", HttpHdrCcType::CC_NO_CACHE}, {"no-store", HttpHdrCcType::CC_NO_STORE}, {"no-transform", HttpHdrCcType::CC_NO_TRANSFORM}, {"must-revalidate", HttpHdrCcType::CC_MUST_REVALIDATE}, {"proxy-revalidate", HttpHdrCcType::CC_PROXY_REVALIDATE}, {"max-age", HttpHdrCcType::CC_MAX_AGE}, {"s-maxage", HttpHdrCcType::CC_S_MAXAGE}, {"max-stale", HttpHdrCcType::CC_MAX_STALE}, {"min-fresh", HttpHdrCcType::CC_MIN_FRESH}, {"only-if-cached", HttpHdrCcType::CC_ONLY_IF_CACHED}, {"stale-if-error", HttpHdrCcType::CC_STALE_IF_ERROR}, {"immutable", HttpHdrCcType::CC_IMMUTABLE}, + {"pre-check", HttpHdrCcType::CC_PRE_CHECK}, + {"post-check", HttpHdrCcType::CC_POST_CHECK}, {"Other,", HttpHdrCcType::CC_OTHER}, /* ',' will protect from matches */ {nullptr, HttpHdrCcType::CC_ENUM_END} }; LookupTable<HttpHdrCcType> ccLookupTable(HttpHdrCcType::CC_OTHER,CcAttrs); std::vector<HttpHeaderFieldStat> ccHeaderStats(HttpHdrCcType::CC_ENUM_END); /// used to walk a table of http_header_cc_type structs HttpHdrCcType &operator++ (HttpHdrCcType &aHeader) { int tmp = (int)aHeader; aHeader = (HttpHdrCcType)(++tmp); return aHeader; } /// Module initialization hook void httpHdrCcInitModule(void) { // check invariant on initialization table for (unsigned int j = 0; CcAttrs[j].name != nullptr; ++j) { @@ -209,40 +211,44 @@ break; case HttpHdrCcType::CC_NO_STORE: noStore(true); break; case HttpHdrCcType::CC_NO_TRANSFORM: noTransform(true); break; case HttpHdrCcType::CC_MUST_REVALIDATE: mustRevalidate(true); break; case HttpHdrCcType::CC_PROXY_REVALIDATE: proxyRevalidate(true); break; case HttpHdrCcType::CC_ONLY_IF_CACHED: onlyIfCached(true); break; case HttpHdrCcType::CC_IMMUTABLE: Immutable(true); break; + case HttpHdrCcType::CC_PRE_CHECK: + case HttpHdrCcType::CC_POST_CHECK: + break; // drop these + case HttpHdrCcType::CC_OTHER: if (other.size()) other.append(", "); other.append(item, ilen); break; default: /* note that we ignore most of '=' specs (RFCVIOLATION) */ break; } } return (mask != 0); } void HttpHdrCc::packInto(Packable * p) const { // optimization: if the mask is empty do nothing @@ -284,40 +290,42 @@ p->appendf("=%d", maxAge()); break; case HttpHdrCcType::CC_S_MAXAGE: p->appendf("=%d", sMaxAge()); break; case HttpHdrCcType::CC_MAX_STALE: /* max-stale's value is optional. If we didn't receive it, don't send it */ if (maxStale()!=MAX_STALE_ANY) p->appendf("=%d", maxStale()); break; case HttpHdrCcType::CC_MIN_FRESH: p->appendf("=%d", minFresh()); break; case HttpHdrCcType::CC_ONLY_IF_CACHED: break; case HttpHdrCcType::CC_STALE_IF_ERROR: p->appendf("=%d", staleIfError()); break; case HttpHdrCcType::CC_IMMUTABLE: + case HttpHdrCcType::CC_PRE_CHECK: + case HttpHdrCcType::CC_POST_CHECK: break; case HttpHdrCcType::CC_OTHER: case HttpHdrCcType::CC_ENUM_END: // done below after the loop break; } ++pcount; } } if (other.size() != 0) p->appendf((pcount ? ", " SQUIDSTRINGPH : SQUIDSTRINGPH), SQUIDSTRINGPRINT(other)); } void httpHdrCcUpdateStats(const HttpHdrCc * cc, StatHist * hist) { assert(cc); === modified file 'src/HttpHdrCc.h' --- src/HttpHdrCc.h 2017-01-07 03:10:12 +0000 +++ src/HttpHdrCc.h 2017-01-26 02:36:24 +0000 @@ -15,40 +15,42 @@ #include "SquidString.h" #include <iosfwd> class Packable; enum HttpHdrCcType : unsigned char { CC_PUBLIC = 0, CC_PRIVATE, CC_NO_CACHE, CC_NO_STORE, CC_NO_TRANSFORM, CC_MUST_REVALIDATE, CC_PROXY_REVALIDATE, CC_MAX_AGE, CC_S_MAXAGE, CC_MAX_STALE, CC_MIN_FRESH, CC_ONLY_IF_CACHED, CC_STALE_IF_ERROR, CC_IMMUTABLE, /* draft-mcmanus-immutable-00 */ + CC_PRE_CHECK, /* obsolete MSIE value to identify and drop */ + CC_POST_CHECK, /* obsolete MSIE value to identify and drop */ CC_OTHER, CC_ENUM_END /* also used to mean "invalid" */ }; /** Http Cache-Control header representation * * Store and parse the Cache-Control HTTP header. */ class HttpHdrCc { MEMPROXY_CLASS(HttpHdrCc); public: static const int32_t MAX_AGE_UNKNOWN=-1; //max-age is unset static const int32_t S_MAXAGE_UNKNOWN=-1; //s-maxage is unset static const int32_t MAX_STALE_UNKNOWN=-1; //max-stale is unset ///used to mark a valueless Cache-Control: max-stale directive, which instructs /// us to treat responses of any age as fresh static const int32_t MAX_STALE_ANY=0x7fffffff; static const int32_t STALE_IF_ERROR_UNKNOWN=-1; //stale_if_error is unset
_______________________________________________ squid-dev mailing list squid-dev@lists.squid-cache.org http://lists.squid-cache.org/listinfo/squid-dev