]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
HTTP/1.1: make Vary:* objects cacheable
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 30 Oct 2016 09:45:03 +0000 (22:45 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 30 Oct 2016 09:45:03 +0000 (22:45 +1300)
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

index 24649aa04db57323ee6d73a4ef76d6d5eac318e9..06bbf0ecf5303dc0185db1007b549c58dff18f01 100644 (file)
@@ -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);
         }
     }