]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
HTTP/1.1: make Vary:* objects cacheable
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 25 Oct 2016 08:03:32 +0000 (21:03 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 25 Oct 2016 08:03:32 +0000 (21:03 +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 4f98545609d3d3a2753818f9370058eabd082ce5..734dbcac549d42e2ba15bc13162d8df408b969aa 100644 (file)
@@ -593,7 +593,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();
@@ -947,6 +947,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);
         }
     }