]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http: update the list of cacheable status codes as per RFC7231
authorWilly Tarreau <w@1wt.eu>
Thu, 21 Dec 2017 10:41:38 +0000 (11:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 22 Dec 2017 13:43:26 +0000 (14:43 +0100)
Since RFC2616, the following codes were added to the list of codes
cacheable by default : 204, 404, 405, 414, 501. For now this it only
checked by the checkcache option to detect cacheable cookies.

doc/configuration.txt
src/proto_http.c

index a4b3652f52a31c58f2769821970f3b3503753875..9c22afe84db6430e0a54a13f629cab581977b589 100644 (file)
@@ -5438,8 +5438,9 @@ no option checkcache
   proxy. When this option is enabled, the only responses which can be delivered
   to the client are :
     - all those without "Set-Cookie" header ;
-    - all those with a return code other than 200, 203, 206, 300, 301, 410,
-      provided that the server has not set a "Cache-control: public" header ;
+    - all those with a return code other than 200, 203, 204, 206, 300, 301,
+      404, 405, 410, 414, 501, provided that the server has not set a
+      "Cache-control: public" header field ;
     - all those that result from a request using a method other than GET, HEAD,
       OPTIONS, TRACE, provided that the server has not set a 'Cache-Control:
       public' header field ;
index ebc72c9e2161ac167a9468e21bc872e9219baffb..3e17021975df57950cf2887b901621882d711b2b 100644 (file)
@@ -5388,15 +5388,24 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
        switch (txn->status) {
        case 200:
        case 203:
+       case 204:
        case 206:
        case 300:
        case 301:
+       case 404:
+       case 405:
        case 410:
-               /* RFC2616 @13.4:
-                *   "A response received with a status code of
-                *    200, 203, 206, 300, 301 or 410 MAY be stored
-                *    by a cache (...) unless a cache-control
-                *    directive prohibits caching."
+       case 414:
+       case 501:
+               /* RFC7231#6.1:
+                *   Responses with status codes that are defined as
+                *   cacheable by default (e.g., 200, 203, 204, 206,
+                *   300, 301, 404, 405, 410, 414, and 501 in this
+                *   specification) can be reused by a cache with
+                *   heuristic expiration unless otherwise indicated
+                *   by the method definition or explicit cache
+                *   controls [RFC7234]; all other status codes are
+                *   not cacheable by default.
                 *
                 * RFC7234#4:
                 *   A cache MUST write through requests with methods