From 39ba8d75e0351afb9a7636d9c366b6b41f189fa5 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 30 Oct 2016 22:45:03 +1300 Subject: [PATCH] HTTP/1.1: make Vary:* objects cacheable Under new clauses from RFC 7231 section 7.1.4 and HTTP response containing header Vary:* (wifcard variant) can be cached, but requires revalidation with server before each use. Use the new mandatory revalidation flags to allow storing of any wildcard Vary:* response. Note that responses with headers like Vary:A,B,C,* are equivalent to Vary:*. The cache key string for these objects is normalized. --- src/http.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/http.cc b/src/http.cc index 24649aa04d..06bbf0ecf5 100644 --- a/src/http.cc +++ b/src/http.cc @@ -594,7 +594,7 @@ assembleVaryKey(String &vary, SBuf &vstr, const HttpRequest &request) while (strListGetItem(&vary, ',', &item, &ilen, &pos)) { SBuf name(item, ilen); if (name == asterisk) { - vstr.clear(); + vstr = asterisk; break; } name.toLower(); @@ -917,6 +917,12 @@ HttpStateData::haveParsedReplyHeaders() varyFailure = true; } else { entry->mem_obj->vary_headers = vary; + + // RFC 7231 section 7.1.4 + // Vary:* can be cached, but has mandatory revalidation + static const SBuf asterisk("*"); + if (vary == asterisk) + EBIT_SET(entry->flags, ENTRY_REVALIDATE_ALWAYS); } } -- 2.47.2