idnits 2.17.1 draft-ietf-httpbis-cache-05.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (July 8, 2019) is 1753 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Unused Reference: 'RFC3986' is defined on line 1518, but no explicit reference was found in the text == Unused Reference: 'RFC7234' is defined on line 1562, but no explicit reference was found in the text == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-messaging-05 -- Possible downref: Normative reference to a draft: ref. 'Messaging' == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-semantics-05 -- Possible downref: Normative reference to a draft: ref. 'Semantics' -- Possible downref: Non-RFC (?) normative reference: ref. 'USASCII' -- Obsolete informational reference (is this intentional?): RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) -- Obsolete informational reference (is this intentional?): RFC 7234 (Obsoleted by RFC 9111) Summary: 0 errors (**), 0 flaws (~~), 6 warnings (==), 7 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 HTTP Working Group R. Fielding, Ed. 3 Internet-Draft Adobe 4 Obsoletes: 7234 (if approved) M. Nottingham, Ed. 5 Intended status: Standards Track Fastly 6 Expires: January 9, 2020 J. Reschke, Ed. 7 greenbytes 8 July 8, 2019 10 HTTP Caching 11 draft-ietf-httpbis-cache-05 13 Abstract 15 The Hypertext Transfer Protocol (HTTP) is a stateless application- 16 level protocol for distributed, collaborative, hypertext information 17 systems. This document defines HTTP caches and the associated header 18 fields that control cache behavior or indicate cacheable response 19 messages. 21 This document obsoletes RFC 7234. 23 Editorial Note 25 This note is to be removed before publishing as an RFC. 27 Discussion of this draft takes place on the HTTP working group 28 mailing list (ietf-http-wg@w3.org), which is archived at 29 . 31 Working Group information can be found at ; 32 source code and issues list for this draft can be found at 33 . 35 The changes in this draft are summarized in Appendix C.6. 37 Status of This Memo 39 This Internet-Draft is submitted in full conformance with the 40 provisions of BCP 78 and BCP 79. 42 Internet-Drafts are working documents of the Internet Engineering 43 Task Force (IETF). Note that other groups may also distribute 44 working documents as Internet-Drafts. The list of current Internet- 45 Drafts is at https://datatracker.ietf.org/drafts/current/. 47 Internet-Drafts are draft documents valid for a maximum of six months 48 and may be updated, replaced, or obsoleted by other documents at any 49 time. It is inappropriate to use Internet-Drafts as reference 50 material or to cite them other than as "work in progress." 52 This Internet-Draft will expire on January 9, 2020. 54 Copyright Notice 56 Copyright (c) 2019 IETF Trust and the persons identified as the 57 document authors. All rights reserved. 59 This document is subject to BCP 78 and the IETF Trust's Legal 60 Provisions Relating to IETF Documents 61 (https://trustee.ietf.org/license-info) in effect on the date of 62 publication of this document. Please review these documents 63 carefully, as they describe your rights and restrictions with respect 64 to this document. Code Components extracted from this document must 65 include Simplified BSD License text as described in Section 4.e of 66 the Trust Legal Provisions and are provided without warranty as 67 described in the Simplified BSD License. 69 This document may contain material from IETF Documents or IETF 70 Contributions published or made publicly available before November 71 10, 2008. The person(s) controlling the copyright in some of this 72 material may not have granted the IETF Trust the right to allow 73 modifications of such material outside the IETF Standards Process. 74 Without obtaining an adequate license from the person(s) controlling 75 the copyright in such materials, this document may not be modified 76 outside the IETF Standards Process, and derivative works of it may 77 not be created outside the IETF Standards Process, except to format 78 it for publication as an RFC or to translate it into languages other 79 than English. 81 Table of Contents 83 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 84 1.1. Requirements Notation . . . . . . . . . . . . . . . . . . 5 85 1.2. Syntax Notation . . . . . . . . . . . . . . . . . . . . . 5 86 1.3. Delta Seconds . . . . . . . . . . . . . . . . . . . . . . 5 87 2. Overview of Cache Operation . . . . . . . . . . . . . . . . . 6 88 3. Storing Responses in Caches . . . . . . . . . . . . . . . . . 7 89 3.1. Storing Incomplete Responses . . . . . . . . . . . . . . 8 90 3.2. Storing Responses to Authenticated Requests . . . . . . . 8 91 3.3. Combining Partial Content . . . . . . . . . . . . . . . . 9 92 4. Constructing Responses from Caches . . . . . . . . . . . . . 9 93 4.1. Calculating Secondary Keys with Vary . . . . . . . . . . 10 94 4.2. Freshness . . . . . . . . . . . . . . . . . . . . . . . . 11 95 4.2.1. Calculating Freshness Lifetime . . . . . . . . . . . 13 96 4.2.2. Calculating Heuristic Freshness . . . . . . . . . . . 13 97 4.2.3. Calculating Age . . . . . . . . . . . . . . . . . . . 14 98 4.2.4. Serving Stale Responses . . . . . . . . . . . . . . . 15 99 4.3. Validation . . . . . . . . . . . . . . . . . . . . . . . 16 100 4.3.1. Sending a Validation Request . . . . . . . . . . . . 16 101 4.3.2. Handling a Received Validation Request . . . . . . . 17 102 4.3.3. Handling a Validation Response . . . . . . . . . . . 18 103 4.3.4. Freshening Stored Responses upon Validation . . . . . 18 104 4.3.5. Freshening Responses with HEAD . . . . . . . . . . . 19 105 4.4. Invalidation . . . . . . . . . . . . . . . . . . . . . . 20 106 5. Header Field Definitions . . . . . . . . . . . . . . . . . . 20 107 5.1. Age . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 108 5.2. Cache-Control . . . . . . . . . . . . . . . . . . . . . . 21 109 5.2.1. Request Cache-Control Directives . . . . . . . . . . 22 110 5.2.1.1. max-age . . . . . . . . . . . . . . . . . . . . . 22 111 5.2.1.2. max-stale . . . . . . . . . . . . . . . . . . . . 23 112 5.2.1.3. min-fresh . . . . . . . . . . . . . . . . . . . . 23 113 5.2.1.4. no-cache . . . . . . . . . . . . . . . . . . . . 23 114 5.2.1.5. no-store . . . . . . . . . . . . . . . . . . . . 24 115 5.2.1.6. no-transform . . . . . . . . . . . . . . . . . . 24 116 5.2.1.7. only-if-cached . . . . . . . . . . . . . . . . . 24 117 5.2.2. Response Cache-Control Directives . . . . . . . . . . 24 118 5.2.2.1. must-revalidate . . . . . . . . . . . . . . . . . 24 119 5.2.2.2. no-cache . . . . . . . . . . . . . . . . . . . . 25 120 5.2.2.3. no-store . . . . . . . . . . . . . . . . . . . . 26 121 5.2.2.4. no-transform . . . . . . . . . . . . . . . . . . 26 122 5.2.2.5. public . . . . . . . . . . . . . . . . . . . . . 26 123 5.2.2.6. private . . . . . . . . . . . . . . . . . . . . . 26 124 5.2.2.7. proxy-revalidate . . . . . . . . . . . . . . . . 27 125 5.2.2.8. max-age . . . . . . . . . . . . . . . . . . . . . 27 126 5.2.2.9. s-maxage . . . . . . . . . . . . . . . . . . . . 27 127 5.2.3. Cache Control Extensions . . . . . . . . . . . . . . 28 128 5.2.4. Cache Directive Registry . . . . . . . . . . . . . . 29 129 5.3. Expires . . . . . . . . . . . . . . . . . . . . . . . . . 29 130 5.4. Pragma . . . . . . . . . . . . . . . . . . . . . . . . . 30 131 5.5. Warning . . . . . . . . . . . . . . . . . . . . . . . . . 30 132 6. Relationship to Applications . . . . . . . . . . . . . . . . 30 133 7. Security Considerations . . . . . . . . . . . . . . . . . . . 31 134 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 32 135 8.1. Header Field Registration . . . . . . . . . . . . . . . . 32 136 8.2. Cache Directive Registration . . . . . . . . . . . . . . 32 137 8.3. Warn Code Registry . . . . . . . . . . . . . . . . . . . 32 138 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 32 139 9.1. Normative References . . . . . . . . . . . . . . . . . . 32 140 9.2. Informative References . . . . . . . . . . . . . . . . . 33 141 Appendix A. Collected ABNF . . . . . . . . . . . . . . . . . . . 35 142 Appendix B. Changes from RFC 7234 . . . . . . . . . . . . . . . 35 143 Appendix C. Change Log . . . . . . . . . . . . . . . . . . . . . 35 144 C.1. Between RFC7234 and draft 00 . . . . . . . . . . . . . . 35 145 C.2. Since draft-ietf-httpbis-cache-00 . . . . . . . . . . . . 36 146 C.3. Since draft-ietf-httpbis-cache-01 . . . . . . . . . . . . 36 147 C.4. Since draft-ietf-httpbis-cache-02 . . . . . . . . . . . . 36 148 C.5. Since draft-ietf-httpbis-cache-03 . . . . . . . . . . . . 37 149 C.6. Since draft-ietf-httpbis-cache-04 . . . . . . . . . . . . 37 150 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 151 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 39 152 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 39 154 1. Introduction 156 The Hypertext Transfer Protocol (HTTP) is a stateless application- 157 level request/response protocol that uses extensible semantics and 158 self-descriptive messages for flexible interaction with network-based 159 hypertext information systems. HTTP is defined by a series of 160 documents that collectively form the HTTP/1.1 specification: 162 o "HTTP Semantics" [Semantics] 164 o "HTTP Caching" (this document) 166 o "HTTP/1.1 Messaging" [Messaging] 168 HTTP is typically used for distributed information systems, where 169 performance can be improved by the use of response caches. This 170 document defines aspects of HTTP related to caching and reusing 171 response messages. 173 An HTTP cache is a local store of response messages and the subsystem 174 that controls storage, retrieval, and deletion of messages in it. A 175 cache stores cacheable responses in order to reduce the response time 176 and network bandwidth consumption on future, equivalent requests. 177 Any client or server MAY employ a cache, though a cache cannot be 178 used by a server that is acting as a tunnel. 180 A shared cache is a cache that stores responses to be reused by more 181 than one user; shared caches are usually (but not always) deployed as 182 a part of an intermediary. A private cache, in contrast, is 183 dedicated to a single user; often, they are deployed as a component 184 of a user agent. 186 The goal of caching in HTTP is to significantly improve performance 187 by reusing a prior response message to satisfy a current request. A 188 stored response is considered "fresh", as defined in Section 4.2, if 189 the response can be reused without "validation" (checking with the 190 origin server to see if the cached response remains valid for this 191 request). A fresh response can therefore reduce both latency and 192 network overhead each time it is reused. When a cached response is 193 not fresh, it might still be reusable if it can be freshened by 194 validation (Section 4.3) or if the origin is unavailable 195 (Section 4.2.4). 197 This document obsoletes RFC 7234, with the changes being summarized 198 in Appendix B. 200 1.1. Requirements Notation 202 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 203 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 204 document are to be interpreted as described in [RFC2119]. 206 Conformance criteria and considerations regarding error handling are 207 defined in Section 3 of [Semantics]. 209 1.2. Syntax Notation 211 This specification uses the Augmented Backus-Naur Form (ABNF) 212 notation of [RFC5234], extended with the notation for case- 213 sensitivity in strings defined in [RFC7405]. 215 It also uses a list extension, defined in Section 11 of [Semantics], 216 that allows for compact definition of comma-separated lists using a 217 '#' operator (similar to how the '*' operator indicates repetition). 218 Appendix A shows the collected grammar with all list operators 219 expanded to standard ABNF notation. 221 The following core rules are included by reference, as defined in 222 [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF 223 (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double quote), 224 HEXDIG (hexadecimal 0-9/A-F/a-f), HTAB (horizontal tab), LF (line 225 feed), OCTET (any 8-bit sequence of data), SP (space), and VCHAR (any 226 visible [USASCII] character). 228 The rules below are defined in [Semantics]: 230 HTTP-date = 231 OWS = 232 field-name = 233 quoted-string = 234 token = 236 1.3. Delta Seconds 238 The delta-seconds rule specifies a non-negative integer, representing 239 time in seconds. 241 delta-seconds = 1*DIGIT 243 A recipient parsing a delta-seconds value and converting it to binary 244 form ought to use an arithmetic type of at least 31 bits of non- 245 negative integer range. If a cache receives a delta-seconds value 246 greater than the greatest integer it can represent, or if any of its 247 subsequent calculations overflows, the cache MUST consider the value 248 to be either 2147483648 (2^31) or the greatest positive integer it 249 can conveniently represent. 251 Note: The value 2147483648 is here for historical reasons, 252 effectively represents infinity (over 68 years), and does not need 253 to be stored in binary form; an implementation could produce it as 254 a canned string if any overflow occurs, even if the calculations 255 are performed with an arithmetic type incapable of directly 256 representing that number. What matters here is that an overflow 257 be detected and not treated as a negative value in later 258 calculations. 260 2. Overview of Cache Operation 262 Proper cache operation preserves the semantics of HTTP transfers 263 ([Semantics]) while reducing the transfer of information already held 264 in the cache. Although caching is an entirely OPTIONAL feature of 265 HTTP, it can be assumed that reusing a cached response is desirable 266 and that such reuse is the default behavior when no requirement or 267 local configuration prevents it. Therefore, HTTP cache requirements 268 are focused on preventing a cache from either storing a non-reusable 269 response or reusing a stored response inappropriately, rather than 270 mandating that caches always store and reuse particular responses. 272 Each cache entry consists of a cache key and one or more HTTP 273 responses corresponding to prior requests that used the same key. 274 The most common form of cache entry is a successful result of a 275 retrieval request: i.e., a 200 (OK) response to a GET request, which 276 contains a representation of the resource identified by the request 277 target (Section 7.3.1 of [Semantics]). However, it is also possible 278 to cache permanent redirects, negative results (e.g., 404 (Not 279 Found)), incomplete results (e.g., 206 (Partial Content)), and 280 responses to methods other than GET if the method's definition allows 281 such caching and defines something suitable for use as a cache key. 283 The primary cache key consists of the request method and target URI. 284 However, since HTTP caches in common use today are typically limited 285 to caching responses to GET, many caches simply decline other methods 286 and use only the URI as the primary cache key. 288 If a request target is subject to content negotiation, its cache 289 entry might consist of multiple stored responses, each differentiated 290 by a secondary key for the values of the original request's selecting 291 header fields (Section 4.1). 293 A cache is disconnected when it cannot contact the origin server or 294 otherwise find a forward path for a given request. A disconnected 295 cache can serve stale responses in some circumstances 296 (Section 4.2.4). 298 3. Storing Responses in Caches 300 A cache MUST NOT store a response to any request, unless: 302 o The request method is understood by the cache and defined as being 303 cacheable, and 305 o the response status code is final (see Section 9.3 of 306 [Messaging]), and 308 o the response status code is understood by the cache, and 310 o the "no-store" cache directive (see Section 5.2) does not appear 311 in the response, and 313 o the "private" response directive (see Section 5.2.2.6) does not 314 appear in the response, if the cache is shared, and 316 o the Authorization header field (see Section 8.5.3 of [Semantics]) 317 does not appear in the request, if the cache is shared, unless the 318 response explicitly allows it (see Section 3.2), and 320 o the response either: 322 * contains an Expires header field (see Section 5.3), or 324 * contains a max-age response directive (see Section 5.2.2.8), or 326 * contains a s-maxage response directive (see Section 5.2.2.9) 327 and the cache is shared, or 329 * contains a Cache Control Extension (see Section 5.2.3) that 330 allows it to be cached, or 332 * has a status code that is defined as cacheable by default (see 333 Section 4.2.2), or 335 * contains a public response directive (see Section 5.2.2.5). 337 Note that any of the requirements listed above can be overridden by a 338 cache-control extension; see Section 5.2.3. 340 In this context, a cache has "understood" a request method or a 341 response status code if it recognizes it and implements all specified 342 caching-related behavior. 344 Note that, in normal operation, some caches will not store a response 345 that has neither a cache validator nor an explicit expiration time, 346 as such responses are not usually useful to store. However, caches 347 are not prohibited from storing such responses. 349 3.1. Storing Incomplete Responses 351 A response message is considered complete when all of the octets 352 indicated by the message framing ([Messaging]) are received prior to 353 the connection being closed. If the request method is GET, the 354 response status code is 200 (OK), and the entire response header 355 section has been received, a cache MAY store an incomplete response 356 message body if the cache entry is recorded as incomplete. Likewise, 357 a 206 (Partial Content) response MAY be stored as if it were an 358 incomplete 200 (OK) cache entry. However, a cache MUST NOT store 359 incomplete or partial-content responses if it does not support the 360 Range and Content-Range header fields or if it does not understand 361 the range units used in those fields. 363 A cache MAY complete a stored incomplete response by making a 364 subsequent range request (Section 8.3 of [Semantics]) and combining 365 the successful response with the stored entry, as defined in 366 Section 3.3. A cache MUST NOT use an incomplete response to answer 367 requests unless the response has been made complete or the request is 368 partial and specifies a range that is wholly within the incomplete 369 response. A cache MUST NOT send a partial response to a client 370 without explicitly marking it as such using the 206 (Partial Content) 371 status code. 373 3.2. Storing Responses to Authenticated Requests 375 A shared cache MUST NOT use a cached response to a request with an 376 Authorization header field (Section 8.5.3 of [Semantics]) to satisfy 377 any subsequent request unless a response directive that allows such 378 responses to be stored is present. 380 In this specification, the following Cache-Control response 381 directives (Section 5.2.2) have such an effect: must-revalidate, 382 public, and s-maxage. 384 3.3. Combining Partial Content 386 A response might transfer only a partial representation if the 387 connection closed prematurely or if the request used one or more 388 Range specifiers (Section 8.3 of [Semantics]). After several such 389 transfers, a cache might have received several ranges of the same 390 representation. A cache MAY combine these ranges into a single 391 stored response, and reuse that response to satisfy later requests, 392 if they all share the same strong validator and the cache complies 393 with the client requirements in Section 9.3.7.3 of [Semantics]. 395 When combining the new response with one or more stored responses, a 396 cache MUST use the header fields provided in the new response, aside 397 from Content-Range, to replace all instances of the corresponding 398 header fields in the stored response. 400 4. Constructing Responses from Caches 402 When presented with a request, a cache MUST NOT reuse a stored 403 response, unless: 405 o The presented effective request URI (Section 5.3 of [Semantics]) 406 and that of the stored response match, and 408 o the request method associated with the stored response allows it 409 to be used for the presented request, and 411 o selecting header fields nominated by the stored response (if any) 412 match those presented (see Section 4.1), and 414 o the stored response does not contain the no-cache cache directive 415 (Section 5.2.2.2), unless it is successfully validated 416 (Section 4.3), and 418 o the stored response is either: 420 * fresh (see Section 4.2), or 422 * allowed to be served stale (see Section 4.2.4), or 424 * successfully validated (see Section 4.3). 426 Note that any of the requirements listed above can be overridden by a 427 cache-control extension; see Section 5.2.3. 429 When a stored response is used to satisfy a request without 430 validation, a cache MUST generate an Age header field (Section 5.1), 431 replacing any present in the response with a value equal to the 432 stored response's current_age; see Section 4.2.3. 434 A cache MUST write through requests with methods that are unsafe 435 (Section 7.2.1 of [Semantics]) to the origin server; i.e., a cache is 436 not allowed to generate a reply to such a request before having 437 forwarded the request and having received a corresponding response. 439 Also, note that unsafe requests might invalidate already-stored 440 responses; see Section 4.4. 442 When more than one suitable response is stored, a cache MUST use the 443 most recent one (as determined by the Date header field). It can 444 also forward the request with "Cache-Control: max-age=0" or "Cache- 445 Control: no-cache" to disambiguate which response to use. 447 A cache that does not have a clock available MUST NOT use stored 448 responses without revalidating them upon every use. 450 4.1. Calculating Secondary Keys with Vary 452 When a cache receives a request that can be satisfied by a stored 453 response that has a Vary header field (Section 10.1.4 of 454 [Semantics]), it MUST NOT use that response unless all of the 455 selecting header fields nominated by the Vary header field match in 456 both the original request (i.e., that associated with the stored 457 response), and the presented request. 459 The selecting header fields from two requests are defined to match if 460 and only if those in the first request can be transformed to those in 461 the second request by applying any of the following: 463 o adding or removing whitespace, where allowed in the header field's 464 syntax 466 o combining multiple header fields with the same field name (see 467 Section 4.2 of [Semantics]) 469 o normalizing both header field values in a way that is known to 470 have identical semantics, according to the header field's 471 specification (e.g., reordering field values when order is not 472 significant; case-normalization, where values are defined to be 473 case-insensitive) 475 If (after any normalization that might take place) a header field is 476 absent from a request, it can only match another request if it is 477 also absent there. 479 A Vary header field-value of "*" always fails to match. 481 The stored response with matching selecting header fields is known as 482 the selected response. 484 If multiple selected responses are available (potentially including 485 responses without a Vary header field), the cache will need to choose 486 one to use. When a selecting header field has a known mechanism for 487 doing so (e.g., qvalues on Accept and similar request header fields), 488 that mechanism MAY be used to select preferred responses; of the 489 remainder, the most recent response (as determined by the Date header 490 field) is used, as per Section 4. 492 If no selected response is available, the cache cannot satisfy the 493 presented request. Typically, it is forwarded to the origin server 494 in a (possibly conditional; see Section 4.3) request. 496 4.2. Freshness 498 A fresh response is one whose age has not yet exceeded its freshness 499 lifetime. Conversely, a stale response is one where it has. 501 A response's freshness lifetime is the length of time between its 502 generation by the origin server and its expiration time. An explicit 503 expiration time is the time at which the origin server intends that a 504 stored response can no longer be used by a cache without further 505 validation, whereas a heuristic expiration time is assigned by a 506 cache when no explicit expiration time is available. 508 A response's age is the time that has passed since it was generated 509 by, or successfully validated with, the origin server. 511 When a response is "fresh" in the cache, it can be used to satisfy 512 subsequent requests without contacting the origin server, thereby 513 improving efficiency. 515 The primary mechanism for determining freshness is for an origin 516 server to provide an explicit expiration time in the future, using 517 either the Expires header field (Section 5.3) or the max-age response 518 directive (Section 5.2.2.8). Generally, origin servers will assign 519 future explicit expiration times to responses in the belief that the 520 representation is not likely to change in a semantically significant 521 way before the expiration time is reached. 523 If an origin server wishes to force a cache to validate every 524 request, it can assign an explicit expiration time in the past to 525 indicate that the response is already stale. Compliant caches will 526 normally validate a stale cached response before reusing it for 527 subsequent requests (see Section 4.2.4). 529 Since origin servers do not always provide explicit expiration times, 530 caches are also allowed to use a heuristic to determine an expiration 531 time under certain circumstances (see Section 4.2.2). 533 The calculation to determine if a response is fresh is: 535 response_is_fresh = (freshness_lifetime > current_age) 537 freshness_lifetime is defined in Section 4.2.1; current_age is 538 defined in Section 4.2.3. 540 Clients can send the max-age or min-fresh request directives 541 (Section 5.2.1) to constrain or relax freshness calculations for the 542 corresponding response. However, caches are not required to honor 543 them. 545 When calculating freshness, to avoid common problems in date parsing: 547 o Although all date formats are specified to be case-sensitive, a 548 cache recipient SHOULD match day, week, and time-zone names case- 549 insensitively. 551 o If a cache recipient's internal implementation of time has less 552 resolution than the value of an HTTP-date, the recipient MUST 553 internally represent a parsed Expires date as the nearest time 554 equal to or earlier than the received value. 556 o A cache recipient MUST NOT allow local time zones to influence the 557 calculation or comparison of an age or expiration time. 559 o A cache recipient SHOULD consider a date with a zone abbreviation 560 other than GMT or UTC to be invalid for calculating expiration. 562 Note that freshness applies only to cache operation; it cannot be 563 used to force a user agent to refresh its display or reload a 564 resource. See Section 6 for an explanation of the difference between 565 caches and history mechanisms. 567 4.2.1. Calculating Freshness Lifetime 569 A cache can calculate the freshness lifetime (denoted as 570 freshness_lifetime) of a response by using the first match of the 571 following: 573 o If the cache is shared and the s-maxage response directive 574 (Section 5.2.2.9) is present, use its value, or 576 o If the max-age response directive (Section 5.2.2.8) is present, 577 use its value, or 579 o If the Expires response header field (Section 5.3) is present, use 580 its value minus the value of the Date response header field, or 582 o Otherwise, no explicit expiration time is present in the response. 583 A heuristic freshness lifetime might be applicable; see 584 Section 4.2.2. 586 Note that this calculation is not vulnerable to clock skew, since all 587 of the information comes from the origin server. 589 When there is more than one value present for a given directive 590 (e.g., two Expires header fields, multiple Cache-Control: max-age 591 directives), the directive's value is considered invalid. Caches are 592 encouraged to consider responses that have invalid freshness 593 information to be stale. 595 4.2.2. Calculating Heuristic Freshness 597 Since origin servers do not always provide explicit expiration times, 598 a cache MAY assign a heuristic expiration time when an explicit time 599 is not specified, employing algorithms that use other header field 600 values (such as the Last-Modified time) to estimate a plausible 601 expiration time. This specification does not provide specific 602 algorithms, but does impose worst-case constraints on their results. 604 A cache MUST NOT use heuristics to determine freshness when an 605 explicit expiration time is present in the stored response. Because 606 of the requirements in Section 3, this means that, effectively, 607 heuristics can only be used on responses without explicit freshness 608 whose status codes are defined as cacheable by default (see 609 Section 9.1 of [Semantics]), and those responses without explicit 610 freshness that have been marked as explicitly cacheable (e.g., with a 611 "public" response directive). 613 If the response has a Last-Modified header field (Section 10.2.2 of 614 [Semantics]), caches are encouraged to use a heuristic expiration 615 value that is no more than some fraction of the interval since that 616 time. A typical setting of this fraction might be 10%. 618 Note: Section 13.9 of [RFC2616] prohibited caches from calculating 619 heuristic freshness for URIs with query components (i.e., those 620 containing '?'). In practice, this has not been widely 621 implemented. Therefore, origin servers are encouraged to send 622 explicit directives (e.g., Cache-Control: no-cache) if they wish 623 to preclude caching. 625 4.2.3. Calculating Age 627 The Age header field is used to convey an estimated age of the 628 response message when obtained from a cache. The Age field value is 629 the cache's estimate of the number of seconds since the response was 630 generated or validated by the origin server. In essence, the Age 631 value is the sum of the time that the response has been resident in 632 each of the caches along the path from the origin server, plus the 633 amount of time it has been in transit along network paths. 635 The following data is used for the age calculation: 637 age_value The term "age_value" denotes the value of the Age header 638 field (Section 5.1), in a form appropriate for arithmetic 639 operation; or 0, if not available. 641 date_value The term "date_value" denotes the value of the Date 642 header field, in a form appropriate for arithmetic operations. 643 See Section 10.1.1.2 of [Semantics] for the definition of the Date 644 header field, and for requirements regarding responses without it. 646 now The term "now" means "the current value of the clock at the host 647 performing the calculation". A host ought to use NTP ([RFC5905]) 648 or some similar protocol to synchronize its clocks to Coordinated 649 Universal Time. 651 request_time The current value of the clock at the host at the time 652 the request resulting in the stored response was made. 654 response_time The current value of the clock at the host at the time 655 the response was received. 657 A response's age can be calculated in two entirely independent ways: 659 1. the "apparent_age": response_time minus date_value, if the local 660 clock is reasonably well synchronized to the origin server's 661 clock. If the result is negative, the result is replaced by 662 zero. 664 2. the "corrected_age_value", if all of the caches along the 665 response path implement HTTP/1.1 or greater. A cache MUST 666 interpret this value relative to the time the request was 667 initiated, not the time that the response was received. 669 apparent_age = max(0, response_time - date_value); 671 response_delay = response_time - request_time; 672 corrected_age_value = age_value + response_delay; 674 These are combined as 676 corrected_initial_age = max(apparent_age, corrected_age_value); 678 unless the cache is confident in the value of the Age header field 679 (e.g., because there are no HTTP/1.0 hops in the Via header field), 680 in which case the corrected_age_value MAY be used as the 681 corrected_initial_age. 683 The current_age of a stored response can then be calculated by adding 684 the amount of time (in seconds) since the stored response was last 685 validated by the origin server to the corrected_initial_age. 687 resident_time = now - response_time; 688 current_age = corrected_initial_age + resident_time; 690 4.2.4. Serving Stale Responses 692 A "stale" response is one that either has explicit expiry information 693 or is allowed to have heuristic expiry calculated, but is not fresh 694 according to the calculations in Section 4.2. 696 A cache MUST NOT generate a stale response if it is prohibited by an 697 explicit in-protocol directive (e.g., by a "no-store" or "no-cache" 698 cache directive, a "must-revalidate" cache-response-directive, or an 699 applicable "s-maxage" or "proxy-revalidate" cache-response-directive; 700 see Section 5.2.2). 702 A cache MUST NOT generate a stale response unless it is disconnected 703 or doing so is explicitly permitted by the client or origin server 704 (e.g., by the max-stale request directive in Section 5.2.1, by 705 extension directives such as those defined in [RFC5861], or by 706 configuration in accordance with an out-of-band contract). 708 4.3. Validation 710 When a cache has one or more stored responses for a requested URI, 711 but cannot serve any of them (e.g., because they are not fresh, or 712 one cannot be selected; see Section 4.1), it can use the conditional 713 request mechanism Section 8.2 of [Semantics] in the forwarded request 714 to give the next inbound server an opportunity to select a valid 715 stored response to use, updating the stored metadata in the process, 716 or to replace the stored response(s) with a new response. This 717 process is known as "validating" or "revalidating" the stored 718 response. 720 4.3.1. Sending a Validation Request 722 When generating a conditional request for validation, a cache starts 723 with either a request it is attempting to satisfy, or -- if it is 724 initiating the request independently -- it synthesises a request 725 using a stored response by copying the method, request-target, and 726 request header fields used for identifying the secondary cache key 727 Section 4.1. 729 It then updates that request with one or more precondition header 730 fields. These contain validator metadata sourced from stored 731 response(s) that have the same cache key (both primary and secondary, 732 as applicable). 734 The precondition header fields are then compared by recipients to 735 determine whether any stored response is equivalent to a current 736 representation of the resource. 738 One such validator is the timestamp given in a Last-Modified header 739 field (Section 10.2.2 of [Semantics]), which can be used in an If- 740 Modified-Since header field for response validation, or in an If- 741 Unmodified-Since or If-Range header field for representation 742 selection (i.e., the client is referring specifically to a previously 743 obtained representation with that timestamp). 745 Another validator is the entity-tag given in an ETag header field 746 (Section 10.2.3 of [Semantics]). One or more entity-tags, indicating 747 one or more stored responses, can be used in an If-None-Match header 748 field for response validation, or in an If-Match or If-Range header 749 field for representation selection (i.e., the client is referring 750 specifically to one or more previously obtained representations with 751 the listed entity-tags). 753 4.3.2. Handling a Received Validation Request 755 Each client in the request chain may have its own cache, so it is 756 common for a cache at an intermediary to receive conditional requests 757 from other (outbound) caches. Likewise, some user agents make use of 758 conditional requests to limit data transfers to recently modified 759 representations or to complete the transfer of a partially retrieved 760 representation. 762 If a cache receives a request that can be satisfied by reusing one of 763 its stored 200 (OK) or 206 (Partial Content) responses, the cache 764 SHOULD evaluate any applicable conditional header field preconditions 765 received in that request with respect to the corresponding validators 766 contained within the selected response. A cache MUST NOT evaluate 767 conditional header fields that are only applicable to an origin 768 server, found in a request with semantics that cannot be satisfied 769 with a cached response, or applied to a target resource for which it 770 has no stored responses; such preconditions are likely intended for 771 some other (inbound) server. 773 The proper evaluation of conditional requests by a cache depends on 774 the received precondition header fields and their precedence, as 775 defined in Section 8.2.2 of [Semantics]. The If-Match and If- 776 Unmodified-Since conditional header fields are not applicable to a 777 cache. 779 A request containing an If-None-Match header field (Section 8.2.4 of 780 [Semantics]) indicates that the client wants to validate one or more 781 of its own stored responses in comparison to whichever stored 782 response is selected by the cache. If the field-value is "*", or if 783 the field-value is a list of entity-tags and at least one of them 784 matches the entity-tag of the selected stored response, a cache 785 recipient SHOULD generate a 304 (Not Modified) response (using the 786 metadata of the selected stored response) instead of sending that 787 stored response. 789 When a cache decides to revalidate its own stored responses for a 790 request that contains an If-None-Match list of entity-tags, the cache 791 MAY combine the received list with a list of entity-tags from its own 792 stored set of responses (fresh or stale) and send the union of the 793 two lists as a replacement If-None-Match header field value in the 794 forwarded request. If a stored response contains only partial 795 content, the cache MUST NOT include its entity-tag in the union 796 unless the request is for a range that would be fully satisfied by 797 that partial stored response. If the response to the forwarded 798 request is 304 (Not Modified) and has an ETag header field value with 799 an entity-tag that is not in the client's list, the cache MUST 800 generate a 200 (OK) response for the client by reusing its 801 corresponding stored response, as updated by the 304 response 802 metadata (Section 4.3.4). 804 If an If-None-Match header field is not present, a request containing 805 an If-Modified-Since header field (Section 8.2.5 of [Semantics]) 806 indicates that the client wants to validate one or more of its own 807 stored responses by modification date. A cache recipient SHOULD 808 generate a 304 (Not Modified) response (using the metadata of the 809 selected stored response) if one of the following cases is true: 1) 810 the selected stored response has a Last-Modified field-value that is 811 earlier than or equal to the conditional timestamp; 2) no Last- 812 Modified field is present in the selected stored response, but it has 813 a Date field-value that is earlier than or equal to the conditional 814 timestamp; or, 3) neither Last-Modified nor Date is present in the 815 selected stored response, but the cache recorded it as having been 816 received at a time earlier than or equal to the conditional 817 timestamp. 819 A cache that implements partial responses to range requests, as 820 defined in Section 8.3 of [Semantics], also needs to evaluate a 821 received If-Range header field (Section 8.2.7 of [Semantics]) with 822 respect to its selected stored response. 824 4.3.3. Handling a Validation Response 826 Cache handling of a response to a conditional request is dependent 827 upon its status code: 829 o A 304 (Not Modified) response status code indicates that the 830 stored response can be updated and reused; see Section 4.3.4. 832 o A full response (i.e., one with a payload body) indicates that 833 none of the stored responses nominated in the conditional request 834 is suitable. Instead, the cache MUST use the full response to 835 satisfy the request and MAY replace the stored response(s). 837 o However, if a cache receives a 5xx (Server Error) response while 838 attempting to validate a response, it can either forward this 839 response to the requesting client, or act as if the server failed 840 to respond. In the latter case, the cache MAY send a previously 841 stored response (see Section 4.2.4). 843 4.3.4. Freshening Stored Responses upon Validation 845 When a cache receives a 304 (Not Modified) response and already has 846 one or more stored 200 (OK) responses for the applicable cache key, 847 the cache needs to identify which (if any) are to be updated by the 848 new information provided, and then do so. 850 The stored response(s) to update are identified by using the first 851 match (if any) of the following: 853 o If the new response contains a strong validator (see 854 Section 10.2.1 of [Semantics]), then that strong validator 855 identifies the selected representation for update. All of the 856 stored responses with the same strong validator are identified for 857 update. If none of the stored responses contain the same strong 858 validator, then the cache MUST NOT use the new response to update 859 any stored responses. 861 o If the new response contains a weak validator and that validator 862 corresponds to one of the cache's stored responses, then the most 863 recent of those matching stored responses is identified for 864 update. 866 o If the new response does not include any form of validator (such 867 as in the case where a client generates an If-Modified-Since 868 request from a source other than the Last-Modified response header 869 field), and there is only one stored response, and that stored 870 response also lacks a validator, then that stored response is 871 identified for update. 873 For each stored response identified for update, the cache MUST use 874 the header fields provided in the 304 (Not Modified) response to 875 replace all instances of the corresponding header fields in the 876 stored response. 878 4.3.5. Freshening Responses with HEAD 880 A response to the HEAD method is identical to what an equivalent 881 request made with a GET would have been, except it lacks a body. 882 This property of HEAD responses can be used to invalidate or update a 883 cached GET response if the more efficient conditional GET request 884 mechanism is not available (due to no validators being present in the 885 stored response) or if transmission of the representation body is not 886 desired even if it has changed. 888 When a cache makes an inbound HEAD request for a given request target 889 and receives a 200 (OK) response, the cache SHOULD update or 890 invalidate each of its stored GET responses that could have been 891 selected for that request (see Section 4.1). 893 For each of the stored responses that could have been selected, if 894 the stored response and HEAD response have matching values for any 895 received validator fields (ETag and Last-Modified) and, if the HEAD 896 response has a Content-Length header field, the value of Content- 897 Length matches that of the stored response, the cache SHOULD update 898 the stored response as described below; otherwise, the cache SHOULD 899 consider the stored response to be stale. 901 If a cache updates a stored response with the metadata provided in a 902 HEAD response, the cache MUST use the header fields provided in the 903 HEAD response to replace all instances of the corresponding header 904 fields in the stored response and append new header fields to the 905 stored response's header section unless otherwise restricted by the 906 Cache-Control header field. 908 4.4. Invalidation 910 Because unsafe request methods (Section 7.2.1 of [Semantics]) such as 911 PUT, POST or DELETE have the potential for changing state on the 912 origin server, intervening caches can use them to keep their contents 913 up to date. 915 A cache MUST invalidate the effective Request URI (Section 5.3 of 916 [Semantics]) as well as the URI(s) in the Location and Content- 917 Location response header fields (if present) when a non-error status 918 code is received in response to an unsafe request method. 920 However, a cache MUST NOT invalidate a URI from a Location or 921 Content-Location response header field if the host part of that URI 922 differs from the host part in the effective request URI (Section 5.3 923 of [Semantics]). This helps prevent denial-of-service attacks. 925 A cache MUST invalidate the effective request URI (Section 5.3 of 926 [Semantics]) when it receives a non-error response to a request with 927 a method whose safety is unknown. 929 Here, a "non-error response" is one with a 2xx (Successful) or 3xx 930 (Redirection) status code. "Invalidate" means that the cache will 931 either remove all stored responses related to the effective request 932 URI or will mark these as "invalid" and in need of a mandatory 933 validation before they can be sent in response to a subsequent 934 request. 936 Note that this does not guarantee that all appropriate responses are 937 invalidated. For example, a state-changing request might invalidate 938 responses in the caches it travels through, but relevant responses 939 still might be stored in other caches that it has not. 941 5. Header Field Definitions 943 This section defines the syntax and semantics of HTTP header fields 944 related to caching. 946 +-------------------+-----------+--------------+ 947 | Header Field Name | Status | Reference | 948 +-------------------+-----------+--------------+ 949 | Age | standard | Section 5.1 | 950 | Cache-Control | standard | Section 5.2 | 951 | Expires | standard | Section 5.3 | 952 | Pragma | standard | Section 5.4 | 953 | Warning | obsoleted | Section 5.5 | 954 +-------------------+-----------+--------------+ 956 Table 1 958 5.1. Age 960 The "Age" header field conveys the sender's estimate of the amount of 961 time since the response was generated or successfully validated at 962 the origin server. Age values are calculated as specified in 963 Section 4.2.3. 965 Age = delta-seconds 967 The Age field-value is a non-negative integer, representing time in 968 seconds (see Section 1.3). 970 The presence of an Age header field implies that the response was not 971 generated or validated by the origin server for this request. 972 However, lack of an Age header field does not imply the origin was 973 contacted, since the response might have been received from an 974 HTTP/1.0 cache that does not implement Age. 976 5.2. Cache-Control 978 The "Cache-Control" header field is used to specify directives for 979 caches along the request/response chain. Such cache directives are 980 unidirectional in that the presence of a directive in a request does 981 not imply that the same directive is present in the response, or to 982 be repeated in it. 984 See Section 5.2.3 for information about how Cache-Control directives 985 defined elsewhere are handled. 987 Note: Some HTTP/1.0 caches might not implement Cache-Control. 989 A proxy, whether or not it implements a cache, MUST pass cache 990 directives through in forwarded messages, regardless of their 991 significance to that application, since the directives might be 992 applicable to all recipients along the request/response chain. It is 993 not possible to target a directive to a specific cache. 995 Cache directives are identified by a token, to be compared case- 996 insensitively, and have an optional argument, that can use both token 997 and quoted-string syntax. For the directives defined below that 998 define arguments, recipients ought to accept both forms, even if one 999 is documented to be preferred. For any directive not defined by this 1000 specification, a recipient MUST accept both forms. 1002 Cache-Control = 1#cache-directive 1004 cache-directive = token [ "=" ( token / quoted-string ) ] 1006 For the cache directives defined below, no argument is defined (nor 1007 allowed) unless stated otherwise. 1009 +------------------+-----------------------------------+ 1010 | Cache Directive | Reference | 1011 +------------------+-----------------------------------+ 1012 | max-age | Section 5.2.1.1, Section 5.2.2.8 | 1013 | max-stale | Section 5.2.1.2 | 1014 | min-fresh | Section 5.2.1.3 | 1015 | must-revalidate | Section 5.2.2.1 | 1016 | no-cache | Section 5.2.1.4, Section 5.2.2.2 | 1017 | no-store | Section 5.2.1.5, Section 5.2.2.3 | 1018 | no-transform | Section 5.2.1.6, Section 5.2.2.4 | 1019 | only-if-cached | Section 5.2.1.7 | 1020 | private | Section 5.2.2.6 | 1021 | proxy-revalidate | Section 5.2.2.7 | 1022 | public | Section 5.2.2.5 | 1023 | s-maxage | Section 5.2.2.9 | 1024 +------------------+-----------------------------------+ 1026 Table 2 1028 5.2.1. Request Cache-Control Directives 1030 This section defines cache request directives. They are advisory; 1031 caches MAY implement them, but are not required to. 1033 5.2.1.1. max-age 1035 Argument syntax: 1037 delta-seconds (see Section 1.3) 1039 The "max-age" request directive indicates that the client prefers a 1040 response whose age is less than or equal to the specified number of 1041 seconds. Unless the max-stale request directive is also present, the 1042 client does not wish to receive a stale response. 1044 This directive uses the token form of the argument syntax: e.g., 1045 'max-age=5' not 'max-age="5"'. A sender SHOULD NOT generate the 1046 quoted-string form. 1048 5.2.1.2. max-stale 1050 Argument syntax: 1052 delta-seconds (see Section 1.3) 1054 The "max-stale" request directive indicates that the client is 1055 willing to accept a response that has exceeded its freshness 1056 lifetime. If a value is present, then the client is willing to 1057 accept a response that has exceeded its freshness lifetime by no more 1058 than the specified number of seconds. If no value is assigned to 1059 max-stale, then the client is willing to accept a stale response of 1060 any age. 1062 This directive uses the token form of the argument syntax: e.g., 1063 'max-stale=10' not 'max-stale="10"'. A sender SHOULD NOT generate 1064 the quoted-string form. 1066 5.2.1.3. min-fresh 1068 Argument syntax: 1070 delta-seconds (see Section 1.3) 1072 The "min-fresh" request directive indicates that the client prefers a 1073 response whose freshness lifetime is no less than its current age 1074 plus the specified time in seconds. That is, the client wants a 1075 response that will still be fresh for at least the specified number 1076 of seconds. 1078 This directive uses the token form of the argument syntax: e.g., 1079 'min-fresh=20' not 'min-fresh="20"'. A sender SHOULD NOT generate 1080 the quoted-string form. 1082 5.2.1.4. no-cache 1084 The "no-cache" request directive indicates that the client prefers 1085 stored response not be used to satisfy the request without successful 1086 validation on the origin server. 1088 5.2.1.5. no-store 1090 The "no-store" request directive indicates that a cache MUST NOT 1091 store any part of either this request or any response to it. This 1092 directive applies to both private and shared caches. "MUST NOT 1093 store" in this context means that the cache MUST NOT intentionally 1094 store the information in non-volatile storage, and MUST make a best- 1095 effort attempt to remove the information from volatile storage as 1096 promptly as possible after forwarding it. 1098 This directive is NOT a reliable or sufficient mechanism for ensuring 1099 privacy. In particular, malicious or compromised caches might not 1100 recognize or obey this directive, and communications networks might 1101 be vulnerable to eavesdropping. 1103 Note that if a request containing this directive is satisfied from a 1104 cache, the no-store request directive does not apply to the already 1105 stored response. 1107 5.2.1.6. no-transform 1109 The "no-transform" request directive indicates that the client is 1110 asking for intermediares (whether or not they implement a cache) to 1111 avoid transforming the payload, as defined in Section 5.5.2 of 1112 [Semantics]. 1114 5.2.1.7. only-if-cached 1116 The "only-if-cached" request directive indicates that the client only 1117 wishes to obtain a stored response. Caches that honor this request 1118 directive SHOULD, upon receiving it, either respond using a stored 1119 response that is consistent with the other constraints of the 1120 request, or respond with a 504 (Gateway Timeout) status code. 1122 5.2.2. Response Cache-Control Directives 1124 This section defines cache response directives. A cache MUST obey 1125 the requirements of the Cache-Control directives defined in this 1126 section. 1128 5.2.2.1. must-revalidate 1130 The "must-revalidate" response directive indicates that once it has 1131 become stale, the response MUST NOT be used to satisfy any other 1132 request without forwarding it for validation and receiving a 1133 successful response; see Section 4.3. 1135 The must-revalidate directive is necessary to support reliable 1136 operation for certain protocol features. In all circumstances a 1137 cache MUST obey the must-revalidate directive; in particular, if a 1138 cache is disconnected, it MUST generate a 504 (Gateway Timeout) 1139 response. 1141 The must-revalidate directive ought to be used by servers if and only 1142 if failure to validate a request on the representation could result 1143 in incorrect operation, such as a silently unexecuted financial 1144 transaction. 1146 The must-revalidate directive also has the effect of allowing a 1147 stored response to be used to satisfy a request with an Authorization 1148 header field; see Section 3.2. 1150 5.2.2.2. no-cache 1152 Argument syntax: 1154 #field-name 1156 The "no-cache" response directive indicates that the response MUST 1157 NOT be used to satisfy any other request without forwarding it for 1158 validation and receiving a successful response; see Section 4.3. 1160 This allows an origin server to prevent a cache from using it to 1161 satisfy a request without contacting it, even by caches that have 1162 been configured to send stale responses. 1164 If the no-cache response directive specifies one or more field-names, 1165 then a cache MAY use the response to satisfy a subsequent request, 1166 subject to any other restrictions on caching. However, any header 1167 fields in the response that have the field-name(s) listed MUST NOT be 1168 sent in the response to a subsequent request without successful 1169 revalidation with the origin server. This allows an origin server to 1170 prevent the re-use of certain header fields in a response, while 1171 still allowing caching of the rest of the response. 1173 The field-names given are not limited to the set of header fields 1174 defined by this specification. Field names are case-insensitive. 1176 This directive uses the quoted-string form of the argument syntax. A 1177 sender SHOULD NOT generate the token form (even if quoting appears 1178 not to be needed for single-entry lists). 1180 Note: Although it has been back-ported to many implementations, some 1181 HTTP/1.0 caches will not recognize or obey this directive. Also, no- 1182 cache response directives with field-names are often handled by 1183 caches as if an unqualified no-cache directive was received; i.e., 1184 the special handling for the qualified form is not widely 1185 implemented. 1187 5.2.2.3. no-store 1189 The "no-store" response directive indicates that a cache MUST NOT 1190 store any part of either the immediate request or response, and MUST 1191 NOT use the response to satisfy any other request. 1193 This directive applies to both private and shared caches. "MUST NOT 1194 store" in this context means that the cache MUST NOT intentionally 1195 store the information in non-volatile storage, and MUST make a best- 1196 effort attempt to remove the information from volatile storage as 1197 promptly as possible after forwarding it. 1199 This directive is NOT a reliable or sufficient mechanism for ensuring 1200 privacy. In particular, malicious or compromised caches might not 1201 recognize or obey this directive, and communications networks might 1202 be vulnerable to eavesdropping. 1204 5.2.2.4. no-transform 1206 The "no-transform" response directive indicates that an intermediary 1207 (regardless of whether it implements a cache) MUST NOT transform the 1208 payload, as defined in Section 5.5.2 of [Semantics]. 1210 5.2.2.5. public 1212 The "public" response directive indicates that any cache MAY store 1213 the response, even if the response would normally be non-cacheable or 1214 cacheable only within a private cache. (See Section 3.2 for 1215 additional details related to the use of public in response to a 1216 request containing Authorization, and Section 3 for details of how 1217 public affects responses that would normally not be stored, due to 1218 their status codes not being defined as cacheable by default; see 1219 Section 4.2.2.) 1221 5.2.2.6. private 1223 Argument syntax: 1225 #field-name 1227 The "private" response directive indicates that the response message 1228 is intended for a single user and MUST NOT be stored by a shared 1229 cache. A private cache MAY store the response and reuse it for later 1230 requests, even if the response would normally be non-cacheable. 1232 If the private response directive specifies one or more field-names, 1233 this requirement is limited to the field-values associated with the 1234 listed response header fields. That is, a shared cache MUST NOT 1235 store the specified field-names(s), whereas it MAY store the 1236 remainder of the response message. 1238 The field-names given are not limited to the set of header fields 1239 defined by this specification. Field names are case-insensitive. 1241 This directive uses the quoted-string form of the argument syntax. A 1242 sender SHOULD NOT generate the token form (even if quoting appears 1243 not to be needed for single-entry lists). 1245 Note: This usage of the word "private" only controls where the 1246 response can be stored; it cannot ensure the privacy of the message 1247 content. Also, private response directives with field-names are 1248 often handled by caches as if an unqualified private directive was 1249 received; i.e., the special handling for the qualified form is not 1250 widely implemented. 1252 5.2.2.7. proxy-revalidate 1254 The "proxy-revalidate" response directive has the same meaning as the 1255 must-revalidate response directive, except that it does not apply to 1256 private caches. 1258 5.2.2.8. max-age 1260 Argument syntax: 1262 delta-seconds (see Section 1.3) 1264 The "max-age" response directive indicates that the response is to be 1265 considered stale after its age is greater than the specified number 1266 of seconds. 1268 This directive uses the token form of the argument syntax: e.g., 1269 'max-age=5' not 'max-age="5"'. A sender SHOULD NOT generate the 1270 quoted-string form. 1272 5.2.2.9. s-maxage 1274 Argument syntax: 1276 delta-seconds (see Section 1.3) 1278 The "s-maxage" response directive indicates that, in shared caches, 1279 the maximum age specified by this directive overrides the maximum age 1280 specified by either the max-age directive or the Expires header 1281 field. The s-maxage directive also implies the semantics of the 1282 proxy-revalidate response directive. 1284 The must-revalidate directive also has the effect of allowing a 1285 stored response to be used to satisfy a request with an Authorization 1286 header field; see Section 3.2. 1288 This directive uses the token form of the argument syntax: e.g., 1289 's-maxage=10' not 's-maxage="10"'. A sender SHOULD NOT generate the 1290 quoted-string form. 1292 5.2.3. Cache Control Extensions 1294 The Cache-Control header field can be extended through the use of one 1295 or more cache-extension tokens, each with an optional value. A cache 1296 MUST ignore unrecognized cache directives. 1298 Informational extensions (those that do not require a change in cache 1299 behavior) can be added without changing the semantics of other 1300 directives. 1302 Behavioral extensions are designed to work by acting as modifiers to 1303 the existing base of cache directives. Both the new directive and 1304 the old directive are supplied, such that applications that do not 1305 understand the new directive will default to the behavior specified 1306 by the old directive, and those that understand the new directive 1307 will recognize it as modifying the requirements associated with the 1308 old directive. In this way, extensions to the existing cache-control 1309 directives can be made without breaking deployed caches. 1311 For example, consider a hypothetical new response directive called 1312 "community" that acts as a modifier to the private directive: in 1313 addition to private caches, any cache that is shared only by members 1314 of the named community is allowed to cache the response. An origin 1315 server wishing to allow the UCI community to use an otherwise private 1316 response in their shared cache(s) could do so by including 1318 Cache-Control: private, community="UCI" 1320 A cache that recognizes such a community cache-extension could 1321 broaden its behavior in accordance with that extension. A cache that 1322 does not recognize the community cache-extension would ignore it and 1323 adhere to the private directive. 1325 New extension directives ought to consider defining: 1327 o What it means for a directive to be specified multiple times, 1328 o When the directive does not take an argument, what it means when 1329 an argument is present, 1331 o When the directive requires an argument, what it means when it is 1332 missing, 1334 o Whether the directive is specific to requests, responses, or able 1335 to be used in either. 1337 5.2.4. Cache Directive Registry 1339 The "Hypertext Transfer Protocol (HTTP) Cache Directive Registry" 1340 defines the namespace for the cache directives. It has been created 1341 and is now maintained at . 1344 A registration MUST include the following fields: 1346 o Cache Directive Name 1348 o Pointer to specification text 1350 Values to be added to this namespace require IETF Review (see 1351 [RFC8126], Section 4.8). 1353 5.3. Expires 1355 The "Expires" header field gives the date/time after which the 1356 response is considered stale. See Section 4.2 for further discussion 1357 of the freshness model. 1359 The presence of an Expires field does not imply that the original 1360 resource will change or cease to exist at, before, or after that 1361 time. 1363 The Expires value is an HTTP-date timestamp, as defined in 1364 Section 10.1.1.1 of [Semantics]. 1366 Expires = HTTP-date 1368 For example 1370 Expires: Thu, 01 Dec 1994 16:00:00 GMT 1372 A cache recipient MUST interpret invalid date formats, especially the 1373 value "0", as representing a time in the past (i.e., "already 1374 expired"). 1376 If a response includes a Cache-Control field with the max-age 1377 directive (Section 5.2.2.8), a recipient MUST ignore the Expires 1378 field. Likewise, if a response includes the s-maxage directive 1379 (Section 5.2.2.9), a shared cache recipient MUST ignore the Expires 1380 field. In both these cases, the value in Expires is only intended 1381 for recipients that have not yet implemented the Cache-Control field. 1383 An origin server without a clock MUST NOT generate an Expires field 1384 unless its value represents a fixed time in the past (always expired) 1385 or its value has been associated with the resource by a system or 1386 user with a reliable clock. 1388 Historically, HTTP required the Expires field-value to be no more 1389 than a year in the future. While longer freshness lifetimes are no 1390 longer prohibited, extremely large values have been demonstrated to 1391 cause problems (e.g., clock overflows due to use of 32-bit integers 1392 for time values), and many caches will evict a response far sooner 1393 than that. 1395 5.4. Pragma 1397 The "Pragma" header field was defined for HTTP/1.0 caches, so that 1398 clients could specify a "no-cache" request (as Cache-Control was not 1399 defined until HTTP/1.1). 1401 However, support for Cache-Control is now widespread. As a result, 1402 this specification deprecates Pragma. 1404 Note: Because the meaning of "Pragma: no-cache" in responses was 1405 never specified, it does not provide a reliable replacement for 1406 "Cache-Control: no-cache" in them. 1408 5.5. Warning 1410 The "Warning" header field was used to carry additional information 1411 about the status or transformation of a message that might not be 1412 reflected in the status code. This specification obsoletes it, as it 1413 is not widely generated or surfaced to users. The information it 1414 carried can be gleaned from examining other header fields, such as 1415 Age. 1417 6. Relationship to Applications 1419 Applications using HTTP often specify additional forms of caching. 1420 For example, Web browsers often have history mechanisms such as 1421 "Back" buttons that can be used to redisplay a representation 1422 retrieved earlier in a session. 1424 Likewise, some Web browsers implement caching of images and other 1425 assets within a page view; they may or may not honor HTTP caching 1426 semantics. 1428 The requirements in this specification do not necessarily apply to 1429 how applications use data after it is retrieved from a HTTP cache. 1430 That is, a history mechanism can display a previous representation 1431 even if it has expired, and an application can use cached data in 1432 other ways beyond its freshness lifetime. 1434 This does not prohibit the application from taking HTTP caching into 1435 account; for example, a history mechanism might tell the user that a 1436 view is stale, or it might honor cache directives (e.g., Cache- 1437 Control: no-store). 1439 7. Security Considerations 1441 This section is meant to inform developers, information providers, 1442 and users of known security concerns specific to HTTP caching. More 1443 general security considerations are addressed in HTTP messaging 1444 [Messaging] and semantics [Semantics]. 1446 Caches expose additional potential vulnerabilities, since the 1447 contents of the cache represent an attractive target for malicious 1448 exploitation. Because cache contents persist after an HTTP request 1449 is complete, an attack on the cache can reveal information long after 1450 a user believes that the information has been removed from the 1451 network. Therefore, cache contents need to be protected as sensitive 1452 information. 1454 In particular, various attacks might be amplified by being stored in 1455 a shared cache; such "cache poisoning" attacks use the cache to 1456 distribute a malicious payload to many clients, and are especially 1457 effective when an attacker can use implementation flaws, elevated 1458 privileges, or other techniques to insert such a response into a 1459 cache. One common attack vector for cache poisoning is to exploit 1460 differences in message parsing on proxies and in user agents; see 1461 Section 6.3 of [Messaging] for the relevant requirements. 1463 Likewise, implementation flaws (as well as misunderstanding of cache 1464 operation) might lead to caching of sensitive information (e.g., 1465 authentication credentials) that is thought to be private, exposing 1466 it to unauthorized parties. 1468 Furthermore, the very use of a cache can bring about privacy 1469 concerns. For example, if two users share a cache, and the first one 1470 browses to a site, the second may be able to detect that the other 1471 has been to that site, because the resources from it load more 1472 quickly, thanks to the cache. 1474 Note that the Set-Cookie response header field [RFC6265] does not 1475 inhibit caching; a cacheable response with a Set-Cookie header field 1476 can be (and often is) used to satisfy subsequent requests to caches. 1477 Servers who wish to control caching of these responses are encouraged 1478 to emit appropriate Cache-Control response header fields. 1480 8. IANA Considerations 1482 The change controller for the following registrations is: "IETF 1483 (iesg@ietf.org) - Internet Engineering Task Force". 1485 8.1. Header Field Registration 1487 Please update the "Hypertext Transfer Protocol (HTTP) Header Field 1488 Registry" registry at 1489 with the header field names listed in the two tables of Section 5. 1491 8.2. Cache Directive Registration 1493 Please update the "Hypertext Transfer Protocol (HTTP) Cache Directive 1494 Registry" at 1495 with the registration procedure of Section 5.2.4 and the cache 1496 directive names summarized in the table of Section 5.2. 1498 8.3. Warn Code Registry 1500 Please add a note to the "Hypertext Transfer Protocol (HTTP) Warn 1501 Codes" registry at 1502 to the effect that Warning is obsoleted. 1504 9. References 1506 9.1. Normative References 1508 [Messaging] 1509 Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, 1510 Ed., "HTTP/1.1 Messaging", draft-ietf-httpbis-messaging-05 1511 (work in progress), July 2019. 1513 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1514 Requirement Levels", BCP 14, RFC 2119, 1515 DOI 10.17487/RFC2119, March 1997, 1516 . 1518 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1519 Resource Identifier (URI): Generic Syntax", STD 66, 1520 RFC 3986, DOI 10.17487/RFC3986, January 2005, 1521 . 1523 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 1524 Specifications: ABNF", STD 68, RFC 5234, 1525 DOI 10.17487/RFC5234, January 2008, 1526 . 1528 [RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", 1529 RFC 7405, DOI 10.17487/RFC7405, December 2014, 1530 . 1532 [Semantics] 1533 Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, 1534 Ed., "HTTP Semantics", draft-ietf-httpbis-semantics-05 1535 (work in progress), July 2019. 1537 [USASCII] American National Standards Institute, "Coded Character 1538 Set -- 7-bit American Standard Code for Information 1539 Interchange", ANSI X3.4, 1986. 1541 9.2. Informative References 1543 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 1544 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 1545 Transfer Protocol -- HTTP/1.1", RFC 2616, 1546 DOI 10.17487/RFC2616, June 1999, 1547 . 1549 [RFC5861] Nottingham, M., "HTTP Cache-Control Extensions for Stale 1550 Content", RFC 5861, DOI 10.17487/RFC5861, April 2010, 1551 . 1553 [RFC5905] Mills, D., Martin, J., Ed., Burbank, J., and W. Kasch, 1554 "Network Time Protocol Version 4: Protocol and Algorithms 1555 Specification", RFC 5905, DOI 10.17487/RFC5905, June 2010, 1556 . 1558 [RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, 1559 DOI 10.17487/RFC6265, April 2011, 1560 . 1562 [RFC7234] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, 1563 Ed., "Hypertext Transfer Protocol (HTTP): Caching", 1564 RFC 7234, DOI 10.17487/RFC7234, June 2014, 1565 . 1567 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 1568 Writing an IANA Considerations Section in RFCs", BCP 26, 1569 RFC 8126, DOI 10.17487/RFC8126, June 2017, 1570 . 1572 Appendix A. Collected ABNF 1574 In the collected ABNF below, list rules are expanded as per 1575 Section 11 of [Semantics]. 1577 Age = delta-seconds 1579 Cache-Control = [ cache-directive ] *( OWS "," OWS [ cache-directive 1580 ] ) 1582 Expires = HTTP-date 1584 HTTP-date = 1586 OWS = 1588 cache-directive = token [ "=" ( token / quoted-string ) ] 1590 delta-seconds = 1*DIGIT 1592 field-name = 1594 quoted-string = 1596 token = 1598 Appendix B. Changes from RFC 7234 1600 The Warning response header was obsoleted. Much of the information 1601 supported by Warning could be gleaned by examining the response), and 1602 the remaining warn-codes -- although potentially useful -- were 1603 entirely advisory, and in practice were not added by caches or 1604 intermediaries. (Section 5.5) 1606 Appendix C. Change Log 1608 This section is to be removed before publishing as an RFC. 1610 C.1. Between RFC7234 and draft 00 1612 The changes were purely editorial: 1614 o Change boilerplate and abstract to indicate the "draft" status, 1615 and update references to ancestor specifications. 1617 o Remove version "1.1" from document title, indicating that this 1618 specification applies to all HTTP versions. 1620 o Adjust historical notes. 1622 o Update links to sibling specifications. 1624 o Replace sections listing changes from RFC 2616 by new empty 1625 sections referring to RFC 723x. 1627 o Remove acknowledgements specific to RFC 723x. 1629 o Move "Acknowledgements" to the very end and make them unnumbered. 1631 C.2. Since draft-ietf-httpbis-cache-00 1633 The changes are purely editorial: 1635 o Moved all extensibility tips, registration procedures, and 1636 registry tables from the IANA considerations to normative 1637 sections, reducing the IANA considerations to just instructions 1638 that will be removed prior to publication as an RFC. 1640 C.3. Since draft-ietf-httpbis-cache-01 1642 o Cite RFC 8126 instead of RFC 5226 () 1645 o In Section 5.4, misleading statement about the relation between 1646 Pragma and Cache-Control (, ) 1649 C.4. Since draft-ietf-httpbis-cache-02 1651 o In Section 3, explain that only final responses are cacheable 1652 () 1654 o In Section 5.2.2, clarify what responses various directives apply 1655 to () 1657 o In Section 4.3.1, clarify the source of validators in conditional 1658 requests () 1660 o Revise Section 6 to apply to more than just History Lists 1661 () 1663 o In Section 5.5, deprecated "Warning" header field 1664 () 1666 o In Section 3.2, remove a spurious note 1667 () 1669 C.5. Since draft-ietf-httpbis-cache-03 1671 o In Section 2, define what a disconnected cache is 1672 () 1674 o In Section 4, clarify language around how to select a response 1675 when more than one matches () 1678 o in Section 4.2.4, mention stale-while-revalidate and stale-if- 1679 error () 1681 o Remove requirements around cache request directives 1682 () 1684 o Deprecate Pragma () 1687 o In Section 3.2 and Section 5.2.2, note effect of some directives 1688 on authenticated requests () 1691 C.6. Since draft-ietf-httpbis-cache-04 1693 o In Section 5.2, remove the registrations for stale-if-error and 1694 stale-while-revalidate which happened in RFC 7234 1695 () 1697 Index 1699 A 1700 Age header field 21 1701 age 11 1703 C 1704 Cache-Control header field 21 1705 cache 4 1706 cache entry 6 1707 cache key 6 1709 E 1710 Expires header field 29 1711 explicit expiration time 11 1713 F 1714 fresh 11 1715 freshness lifetime 11 1717 G 1718 Grammar 1719 Age 21 1720 ALPHA 5 1721 Cache-Control 22 1722 cache-directive 22 1723 CR 5 1724 CRLF 5 1725 CTL 5 1726 delta-seconds 6 1727 DIGIT 5 1728 DQUOTE 5 1729 Expires 29 1730 HEXDIG 5 1731 HTAB 5 1732 LF 5 1733 OCTET 5 1734 SP 5 1735 VCHAR 5 1737 H 1738 heuristic expiration time 11 1740 M 1741 max-age (cache directive) 22, 27 1742 max-stale (cache directive) 23 1743 min-fresh (cache directive) 23 1744 must-revalidate (cache directive) 24 1746 N 1747 no-cache (cache directive) 23, 25 1748 no-store (cache directive) 24, 26 1749 no-transform (cache directive) 24, 26 1751 O 1752 only-if-cached (cache directive) 24 1754 P 1755 Pragma header field 30 1756 private (cache directive) 26 1757 private cache 4 1758 proxy-revalidate (cache directive) 27 1759 public (cache directive) 26 1761 S 1762 s-maxage (cache directive) 27 1763 shared cache 4 1764 stale 11 1765 strong validator 19 1767 V 1768 validator 16 1770 W 1771 Warning header field 30 1773 Acknowledgments 1775 See Appendix "Acknowledgments" of [Semantics]. 1777 Authors' Addresses 1779 Roy T. Fielding (editor) 1780 Adobe 1781 345 Park Ave 1782 San Jose, CA 95110 1783 USA 1785 EMail: fielding@gbiv.com 1786 URI: https://roy.gbiv.com/ 1788 Mark Nottingham (editor) 1789 Fastly 1791 EMail: mnot@mnot.net 1792 URI: https://www.mnot.net/ 1794 Julian F. Reschke (editor) 1795 greenbytes GmbH 1796 Hafenweg 16 1797 Muenster, NW 48155 1798 Germany 1800 EMail: julian.reschke@greenbytes.de 1801 URI: https://greenbytes.de/tech/webdav/