HTTPWorking GroupM. Nottingham Internet-Draft Fastly Intended status: Standards TrackJanuary 27,November 2, 2019 Expires:July 31, 2019May 5, 2020 TheCacheCache-Status HTTP Response Headerdraft-ietf-httpbis-cache-header-00draft-ietf-httpbis-cache-header-01 Abstract To aid debugging, HTTP caches often append headers to a response detailing how they handled the request. This specification codifies that practice and updates it for HTTP's current caching model. Note to Readers _RFC EDITOR: please remove this section before publication_ Discussion of this draft takes place on the HTTP working group mailing list (ietf-http-wg@w3.org), which is archived at https://lists.w3.org/Archives/Public/ietf-http-wg/ [1]. Working Group information can be found at https://httpwg.org/ [2]; source code and issues list for this draft can be found at https://github.com/httpwg/http-extensions/labels/cache-header [3]. Status of This Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at https://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire onJuly 31, 2019.May 5, 2020. Copyright Notice Copyright (c) 2019 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 3 2. TheCacheCache-Status HTTP Response Header . . . . . . . . . . . . 3 2.1. The fwd parameter . . . . . .3. . . . . . . . . . . . . . 4 2.2. The fwd-res parameter . . . . . . . . . . . . . . . . . . 4 2.3. The fwd-stored parameter . . . . . . . . . . . . . . . . 4 2.4. The res-fresh parameter . . . . . . . . . . . . . . . . . 5 2.5. The cache-fresh parameter . . . . . . . . . . . . . . . . 5 2.6. The collapse-hit parameter . . . . . . . . . . . . . . . 5 2.7. The collapse-wait parameter . . . . . . . . . . . . . . . 5 2.8. The key parameter . . . . . . . . . . . . . . . . . . . . 5 3. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4. Security Considerations . . . . . . . . . . . . . . . . . . . 64.5. References . . . . . . . . . . . . . . . . . . . . . . . . .6 4.1.7 5.1. Normative References . . . . . . . . . . . . . . . . . .6 4.2.7 5.2. Informative References . . . . . . . . . . . . . . . . . 74.3.5.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . .78 Author's Address . . . . . . . . . . . . . . . . . . . . . . . .78 1. Introduction To aid debugging, HTTP caches often append headers to a response detailing how they handled the request. Unfortunately, the semantics of these headers are often unclear, and both the semantics and syntax used vary greatly between implementations. This specification defines a single, new HTTP response header field,"Cache""Cache-Status" for this purpose.For example: Cache: HIT_FRESH; node="reverse-proxy.example.com:80"; key="https://example.com/foo|Accept-Encoding:gzip", HIT_STALE; node="FooCDN parent"; fresh=-45; age=200; latency=3, MISS; node="FooCDN edge"; fresh=-45; age=200; latency=981.1. Notational Conventions The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. This document uses ABNF as defined in [RFC5234], along with the "%s" extension for case sensitivity defined in [RFC7405]. 2. TheCacheCache-Status HTTP Response Header TheCacheCache-Status HTTP response header indicatesthecaches' handling of the request corresponding to the response it occurswithin by caches along the path.within. Its value is aParameterisedList [I-D.ietf-httpbis-header-structure]:CacheCache-Status =sh-param-listsh-list Each member of the parameterised list represents a cache that has handled the request. The first member of the list represents the cache closest to the origin server, and the last member of the list represents the cache closest to the user agent (possibly including the user agent's cache itself, if it chooses to append a value). Caches determine when it is appropriate to add theCacheCache-Status header field to a response. Some might decide to add it to all responses, whereas others might only do so when specifically configured to, or when the request contains a header that activates a debugging mode. When adding a value to theCacheCache-Status header field, caches SHOULD preserve the existing contents of the header, to allow debugging of the entire chain of caches handling the request.Identifiers in the parameterisedThe list membersare expected to be cache-actions: cache-action = %s"HIT_FRESH" / %s"HIT_STALE" / %s"HIT_REFRESH_MODIFIED" / %s"HIT_REFRESH_NOT_MODIFIED" / %s"HIT_REFRESH_STALE" / %s"MISS" / %s"MISS_CLIENT" / %s"BYPASS" / %s"ERROR" The semantics of cache-actions are: o HIT_FRESH - The cache used a fresh stored response to satisfyidentify therequest without going forward o HIT_STALE - Thecacheusedthat inserted the value, and MUST have astale stored response to satisfytype of either sh-string or sh-token. Depending on therequest without going forward o HIT_REFRESH_MODIFIED - The cache haddeployment, this might be astale stored response, went forward to validate it,product or service name (e.g., ExampleCache or "Example CDN"), a hostname ("cache-3.example.com"), andusedIP address, or a generated string. Each member of thenew responselist can also have a number of parameters that describe that cache's handling of the request. While all of these parameters are OPTIONAL, caches are encouraged tosatisfyprovide as much information as possible. fwd = sh-token fwd-res = sh-token fwd-stored = sh-boolean res-fresh = sh-integer cache-fresh = sh-integer collapse-hit = sh-boolean collapse-wait = sh-integer key = sh-string 2.1. The fwd parameter "fwd" indicates why the requesto HIT_REFRESH_NOT_MODIFIED - The cache had a stale stored response,wentforward to validate it, and usedforward. If it is not present, thestored responsevalue defaults tosatisfy"none". It can have one of therequest o HIT_REFRESH_STALEfollowing values: * none - Thecache hadrequest did not go forward; i.e., it was astale stored response, went forward to validate it,hit, andencountered a problem, sowas served from thestored responsecache. * bypass - The cache wasusedconfigured tosatisfy thenot handle this requesto MISS* uri- miss - The cache did nothave a stored response, socontain any responses that matched the requestwas forwarded o MISS_CLIENTURI * vary-miss - Theclient included request directives (e.g., Pragma, Cache-Control) that prevented thecachefrom returningcontained aresponse, soresponse that matched the requestwas forwarded o BYPASSURI, but could not select a response based upon this request's headers. * miss - The cachewas configureddid not contain any responses that could be used toforward thesatisfy this requestwithout attempting(to be used when an implementation cannot distinguish between uri-miss and vary-miss) * res-stale - The cache was able touseselect astoredresponseo ERRORfor the request, but it was stale * req-stale - The cache wasunableable touseselect astoredfresh responseor obtain one by going forward Caches SHOULD usefor themost specific cache-action to a given response,request, butareclient request headers (e.g., Cache- Control request directives) did notrequired toallow its useall cache-actions. Future updates to this specification can add additional cache-actions. Each member2.2. The fwd-res parameter "fwd-res" indicates what the result of theCache headerforward request was. It is only valid when fwd is "res-stale" or "req-stale", and defaults to "full" if not present when fwd is one of those values. It canalsohaveany (or all, or none)one of the followingparameters: node = sh-string fresh = sh-integer age = sh-integer cacheable = sh-boolean key = sh-string latency = sh-integer cl_nm = sh-boolean Their semantics are: o "node"values: * full - indicates that the response was astring identifying forcomplete response (any status code except 304 Not Modified and 206 Partial Response) * partial - indicates that thecache node. MAY beresponse was ahostname, IP address, or alias. o "fresh"206 Partial Response * notmod -an integer indicatingindicates that thecache's estimation ofresponse was a 304 Not Modified 2.3. The fwd-stored parameter "fwd-stored" indicates whether the cache stored the response; a true value indicates that it did. Only valid when fwd is not "none". 2.4. The res-fresh parameter "res-fresh" indicates the response's remaining freshness lifetime([RFC7234],(as per [I-D.ietf-httpbis-cache], Section4.2.1) of this response in seconds, including any locally applied configuration. MAY be negative. o "age" -4.2.1), as an integerindicating the cache's estimationnumber of seconds. This does not include freshness assigned by theage ([RFC7234], Section 4.2.3)cache (see "cache-fresh"). May be negative, to indicate staleness. 2.5. The cache-fresh parameter "cache-fresh" indicates the response's remaining freshness lifetime as calculated by the cache, as an integer number ofthis response inseconds.MUST be 0 or greater. o "cacheable" - a boolean indicating whetherThis includes freshness assigned by thecache can store this response, accordingcache; e.g., through heuristics, local configuration, or other factors. May be negative, to[RFC7234], Section 3indicate staleness. If both cache-fresh andany locally applied configuration. o "key" - a string representingres-fresh appear as parameters on thekeysame value, it implies that the cachehas associated withfreshness overrode the response freshness. 2.6. The collapse-hit parameter "collapse-hit" indicates whether thisresponse. This might includerequest was collapsed together with one or more other forward requests; if true, the response was successfully reused; if not, a new requestURL,had to be made. If not present, the requestheaders, and other values. o "latency" - an integer indicatingwas not collapsed with others. 2.7. The collapse-wait parameter "collapse-wait" indicates the amount of timein milliseconds betweenthat thereceipt of a complete set of request headers and sendingcache held thecomplete setrequest while waiting to see if it could be successfully collapsed, as an integer number ofresponse headersmilliseconds. 2.8. The key parameter "key" conveys a representation ofthis response, fromtheviewpoint ofcache key used for thecache.response. Note that this maynot include buffering time in transport protocols and similar delays. o "cl_nm" -be implementation-specific. 3. Examples The most minimal cache hit: Cache-Status: ExampleCache ... but aboolean indicating whether the response topolite cache will give some more information, e.g.: Cache-Status: ExampleCache; res-fresh=376 A "negative" hit (i.e., theclient hadcache imposed its own freshness lifetime): Cache-Status: ExampleCache; cache-fresh=415 A stale hit just has negative freshness: Cache-Status: ExampleCache; res-fresh=-412 Whereas a304 Not Modified status code. While all of these parameters are OPTIONAL, caches are encouraged to usecomplete miss is: Cache-Status: ExampleCache; fwd=uri-miss A miss that validated on the'node' parameterback-end server: Cache-Status: ExampleCache; fwd=res-stale; fwd-res=notmod A miss that was collapsed with another request: Cache-Status: ExampleCache; fwd=uri-miss; collapse-hit=?1 A miss that the cache attempted toidentify themselves. 3.collapse, but couldn't: Cache-Status: ExampleCache; fwd=uri-miss; collapse-hit=?0; collapse-wait=240 Going through two layers of caching, both of which were hits, and the second collapsed with other requests: Cache-Status: "CDN Company Here"; res-fresh=545, OriginCache; cache-fresh=1100; collapse-hit=?1 4. Security Considerations Information about a cache's content can be used to infer the activity of those using it. Generally, access to sensitive information in a cache is limited to those who are authorised to access that information (using a variety of techniques), so this does not represent an attack vector in the general sense. However, if theCacheCache-Status header is exposed to parties who are not authorised to obtain the response it occurs within, it could expose information about that data. For example, if an attacker were able to obtain theCacheCache-Status header from a response containing sensitive information and access were limited to one person (or limited set of people), they could determine whether that information had been accessed before. This is similar to the information exposed by various timing attacks, but is arguably more reliable, since the cache is directly reporting its state. Mitigations include use of encryption (e.g., TLS [RFC8446])) to protect the response, and careful controls over access to response headers (as are present in the Web platform). When in doubt, theCacheCache-Status header field can be omitted.4.5. References4.1.5.1. Normative References [I-D.ietf-httpbis-cache] Fielding, R., Nottingham, M., and J. Reschke, "HTTP Caching", draft-ietf-httpbis-cache-05 (work in progress), July 2019. [I-D.ietf-httpbis-header-structure] Nottingham, M. and P. Kamp, "Structured Headers for HTTP",draft-ietf-httpbis-header-structure-09draft-ietf-httpbis-header-structure-13 (work in progress),December 2018.August 2019. [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <https://www.rfc-editor.org/info/rfc2119>. [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, DOI 10.17487/RFC5234, January 2008, <https://www.rfc-editor.org/info/rfc5234>.[RFC7234] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Caching", RFC 7234, DOI 10.17487/RFC7234, June 2014, <https://www.rfc-editor.org/info/rfc7234>.[RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", RFC 7405, DOI 10.17487/RFC7405, December 2014, <https://www.rfc-editor.org/info/rfc7405>. [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, <https://www.rfc-editor.org/info/rfc8174>.4.2.5.2. Informative References [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, <https://www.rfc-editor.org/info/rfc8446>.4.3.5.3. URIs [1] https://lists.w3.org/Archives/Public/ietf-http-wg/ [2] https://httpwg.org/ [3] https://github.com/httpwg/http-extensions/labels/cache-header Author's Address Mark Nottingham Fastly Email: mnot@mnot.net URI: https://www.mnot.net/