idnits 2.17.00 (12 Aug 2021) /tmp/idnits33719/draft-ietf-httpbis-cache-04.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 (March 9, 2019) is 1168 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-04 -- Possible downref: Normative reference to a draft: ref. 'Messaging' == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-semantics-04 -- 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) Summary: 0 errors (**), 0 flaws (~~), 6 warnings (==), 6 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: September 10, 2019 J. Reschke, Ed. 7 greenbytes 8 March 9, 2019 10 HTTP Caching 11 draft-ietf-httpbis-cache-04 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.5. 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 September 10, 2019. 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 . . . . . . . . . . . . . . . . . . . . . . 6 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 . . . . . . . 9 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 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 150 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 39 151 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 39 153 1. Introduction 155 The Hypertext Transfer Protocol (HTTP) is a stateless application- 156 level request/response protocol that uses extensible semantics and 157 self-descriptive messages for flexible interaction with network-based 158 hypertext information systems. HTTP is defined by a series of 159 documents that collectively form the HTTP/1.1 specification: 161 o "HTTP Semantics" [Semantics] 163 o "HTTP Caching" (this document) 165 o "HTTP/1.1 Messaging" [Messaging] 167 HTTP is typically used for distributed information systems, where 168 performance can be improved by the use of response caches. This 169 document defines aspects of HTTP related to caching and reusing 170 response messages. 172 An HTTP cache is a local store of response messages and the subsystem 173 that controls storage, retrieval, and deletion of messages in it. A 174 cache stores cacheable responses in order to reduce the response time 175 and network bandwidth consumption on future, equivalent requests. 176 Any client or server MAY employ a cache, though a cache cannot be 177 used by a server that is acting as a tunnel. 179 A shared cache is a cache that stores responses to be reused by more 180 than one user; shared caches are usually (but not always) deployed as 181 a part of an intermediary. A private cache, in contrast, is 182 dedicated to a single user; often, they are deployed as a component 183 of a user agent. 185 The goal of caching in HTTP is to significantly improve performance 186 by reusing a prior response message to satisfy a current request. A 187 stored response is considered "fresh", as defined in Section 4.2, if 188 the response can be reused without "validation" (checking with the 189 origin server to see if the cached response remains valid for this 190 request). A fresh response can therefore reduce both latency and 191 network overhead each time it is reused. When a cached response is 192 not fresh, it might still be reusable if it can be freshened by 193 validation (Section 4.3) or if the origin is unavailable 194 (Section 4.2.4). 196 This document obsoletes RFC 7234, with the changes being summarized 197 in Appendix B. 199 1.1. Requirements Notation 201 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 202 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 203 document are to be interpreted as described in [RFC2119]. 205 Conformance criteria and considerations regarding error handling are 206 defined in Section 3 of [Semantics]. 208 1.2. Syntax Notation 210 This specification uses the Augmented Backus-Naur Form (ABNF) 211 notation of [RFC5234], extended with the notation for case- 212 sensitivity in strings defined in [RFC7405]. 214 It also uses a list extension, defined in Section 11 of [Semantics], 215 that allows for compact definition of comma-separated lists using a 216 '#' operator (similar to how the '*' operator indicates repetition). 217 Appendix A shows the collected grammar with all list operators 218 expanded to standard ABNF notation. 220 The following core rules are included by reference, as defined in 221 [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF 222 (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double quote), 223 HEXDIG (hexadecimal 0-9/A-F/a-f), HTAB (horizontal tab), LF (line 224 feed), OCTET (any 8-bit sequence of data), SP (space), and VCHAR (any 225 visible [USASCII] character). 227 The rules below are defined in [Semantics]: 229 HTTP-date = 230 OWS = 231 field-name = 232 quoted-string = 233 token = 234 uri-host = 235 port = 236 pseudonym = 238 1.3. Delta Seconds 240 The delta-seconds rule specifies a non-negative integer, representing 241 time in seconds. 243 delta-seconds = 1*DIGIT 245 A recipient parsing a delta-seconds value and converting it to binary 246 form ought to use an arithmetic type of at least 31 bits of non- 247 negative integer range. If a cache receives a delta-seconds value 248 greater than the greatest integer it can represent, or if any of its 249 subsequent calculations overflows, the cache MUST consider the value 250 to be either 2147483648 (2^31) or the greatest positive integer it 251 can conveniently represent. 253 Note: The value 2147483648 is here for historical reasons, 254 effectively represents infinity (over 68 years), and does not need 255 to be stored in binary form; an implementation could produce it as 256 a canned string if any overflow occurs, even if the calculations 257 are performed with an arithmetic type incapable of directly 258 representing that number. What matters here is that an overflow 259 be detected and not treated as a negative value in later 260 calculations. 262 2. Overview of Cache Operation 264 Proper cache operation preserves the semantics of HTTP transfers 265 ([Semantics]) while reducing the transfer of information already held 266 in the cache. Although caching is an entirely OPTIONAL feature of 267 HTTP, it can be assumed that reusing a cached response is desirable 268 and that such reuse is the default behavior when no requirement or 269 local configuration prevents it. Therefore, HTTP cache requirements 270 are focused on preventing a cache from either storing a non-reusable 271 response or reusing a stored response inappropriately, rather than 272 mandating that caches always store and reuse particular responses. 274 Each cache entry consists of a cache key and one or more HTTP 275 responses corresponding to prior requests that used the same key. 276 The most common form of cache entry is a successful result of a 277 retrieval request: i.e., a 200 (OK) response to a GET request, which 278 contains a representation of the resource identified by the request 279 target (Section 7.3.1 of [Semantics]). However, it is also possible 280 to cache permanent redirects, negative results (e.g., 404 (Not 281 Found)), incomplete results (e.g., 206 (Partial Content)), and 282 responses to methods other than GET if the method's definition allows 283 such caching and defines something suitable for use as a cache key. 285 The primary cache key consists of the request method and target URI. 286 However, since HTTP caches in common use today are typically limited 287 to caching responses to GET, many caches simply decline other methods 288 and use only the URI as the primary cache key. 290 If a request target is subject to content negotiation, its cache 291 entry might consist of multiple stored responses, each differentiated 292 by a secondary key for the values of the original request's selecting 293 header fields (Section 4.1). 295 A cache is disconnected when it cannot contact the origin server or 296 otherwise find a forward path for a given request. A disconnected 297 cache can serve stale responses in some circumstances 298 (Section 4.2.4). 300 3. Storing Responses in Caches 302 A cache MUST NOT store a response to any request, unless: 304 o The request method is understood by the cache and defined as being 305 cacheable, and 307 o the response status code is final (see Section 9.3 of 308 [Messaging]), and 310 o the response status code is understood by the cache, and 312 o the "no-store" cache directive (see Section 5.2) does not appear 313 in the response, and 315 o the "private" response directive (see Section 5.2.2.6) does not 316 appear in the response, if the cache is shared, and 318 o the Authorization header field (see Section 8.5.3 of [Semantics]) 319 does not appear in the request, if the cache is shared, unless the 320 response explicitly allows it (see Section 3.2), and 322 o the response either: 324 * contains an Expires header field (see Section 5.3), or 326 * contains a max-age response directive (see Section 5.2.2.8), or 328 * contains a s-maxage response directive (see Section 5.2.2.9) 329 and the cache is shared, or 331 * contains a Cache Control Extension (see Section 5.2.3) that 332 allows it to be cached, or 334 * has a status code that is defined as cacheable by default (see 335 Section 4.2.2), or 337 * contains a public response directive (see Section 5.2.2.5). 339 Note that any of the requirements listed above can be overridden by a 340 cache-control extension; see Section 5.2.3. 342 In this context, a cache has "understood" a request method or a 343 response status code if it recognizes it and implements all specified 344 caching-related behavior. 346 Note that, in normal operation, some caches will not store a response 347 that has neither a cache validator nor an explicit expiration time, 348 as such responses are not usually useful to store. However, caches 349 are not prohibited from storing such responses. 351 3.1. Storing Incomplete Responses 353 A response message is considered complete when all of the octets 354 indicated by the message framing ([Messaging]) are received prior to 355 the connection being closed. If the request method is GET, the 356 response status code is 200 (OK), and the entire response header 357 section has been received, a cache MAY store an incomplete response 358 message body if the cache entry is recorded as incomplete. Likewise, 359 a 206 (Partial Content) response MAY be stored as if it were an 360 incomplete 200 (OK) cache entry. However, a cache MUST NOT store 361 incomplete or partial-content responses if it does not support the 362 Range and Content-Range header fields or if it does not understand 363 the range units used in those fields. 365 A cache MAY complete a stored incomplete response by making a 366 subsequent range request (Section 8.3 of [Semantics]) and combining 367 the successful response with the stored entry, as defined in 368 Section 3.3. A cache MUST NOT use an incomplete response to answer 369 requests unless the response has been made complete or the request is 370 partial and specifies a range that is wholly within the incomplete 371 response. A cache MUST NOT send a partial response to a client 372 without explicitly marking it as such using the 206 (Partial Content) 373 status code. 375 3.2. Storing Responses to Authenticated Requests 377 A shared cache MUST NOT use a cached response to a request with an 378 Authorization header field (Section 8.5.3 of [Semantics]) to satisfy 379 any subsequent request unless a response directive that allows such 380 responses to be stored is present. 382 In this specification, the following Cache-Control response 383 directives (Section 5.2.2) have such an effect: must-revalidate, 384 public, and s-maxage. 386 3.3. Combining Partial Content 388 A response might transfer only a partial representation if the 389 connection closed prematurely or if the request used one or more 390 Range specifiers (Section 8.3 of [Semantics]). After several such 391 transfers, a cache might have received several ranges of the same 392 representation. A cache MAY combine these ranges into a single 393 stored response, and reuse that response to satisfy later requests, 394 if they all share the same strong validator and the cache complies 395 with the client requirements in Section 9.3.7.3 of [Semantics]. 397 When combining the new response with one or more stored responses, a 398 cache MUST use the header fields provided in the new response, aside 399 from Content-Range, to replace all instances of the corresponding 400 header fields in the stored response. 402 4. Constructing Responses from Caches 404 When presented with a request, a cache MUST NOT reuse a stored 405 response, unless: 407 o The presented effective request URI (Section 5.3 of [Semantics]) 408 and that of the stored response match, and 410 o the request method associated with the stored response allows it 411 to be used for the presented request, and 413 o selecting header fields nominated by the stored response (if any) 414 match those presented (see Section 4.1), and 416 o the stored response does not contain the no-cache cache directive 417 (Section 5.2.2.2), unless it is successfully validated 418 (Section 4.3), and 420 o the stored response is either: 422 * fresh (see Section 4.2), or 424 * allowed to be served stale (see Section 4.2.4), or 426 * successfully validated (see Section 4.3). 428 Note that any of the requirements listed above can be overridden by a 429 cache-control extension; see Section 5.2.3. 431 When a stored response is used to satisfy a request without 432 validation, a cache MUST generate an Age header field (Section 5.1), 433 replacing any present in the response with a value equal to the 434 stored response's current_age; see Section 4.2.3. 436 A cache MUST write through requests with methods that are unsafe 437 (Section 7.2.1 of [Semantics]) to the origin server; i.e., a cache is 438 not allowed to generate a reply to such a request before having 439 forwarded the request and having received a corresponding response. 441 Also, note that unsafe requests might invalidate already-stored 442 responses; see Section 4.4. 444 When more than one suitable response is stored, a cache MUST use the 445 most recent one (as determined by the Date header field). It can 446 also forward the request with "Cache-Control: max-age=0" or "Cache- 447 Control: no-cache" to disambiguate which response to use. 449 A cache that does not have a clock available MUST NOT use stored 450 responses without revalidating them upon every use. 452 4.1. Calculating Secondary Keys with Vary 454 When a cache receives a request that can be satisfied by a stored 455 response that has a Vary header field (Section 10.1.4 of 456 [Semantics]), it MUST NOT use that response unless all of the 457 selecting header fields nominated by the Vary header field match in 458 both the original request (i.e., that associated with the stored 459 response), and the presented request. 461 The selecting header fields from two requests are defined to match if 462 and only if those in the first request can be transformed to those in 463 the second request by applying any of the following: 465 o adding or removing whitespace, where allowed in the header field's 466 syntax 468 o combining multiple header fields with the same field name (see 469 Section 4.2 of [Semantics]) 471 o normalizing both header field values in a way that is known to 472 have identical semantics, according to the header field's 473 specification (e.g., reordering field values when order is not 474 significant; case-normalization, where values are defined to be 475 case-insensitive) 477 If (after any normalization that might take place) a header field is 478 absent from a request, it can only match another request if it is 479 also absent there. 481 A Vary header field-value of "*" always fails to match. 483 The stored response with matching selecting header fields is known as 484 the selected response. 486 If multiple selected responses are available (potentially including 487 responses without a Vary header field), the cache will need to choose 488 one to use. When a selecting header field has a known mechanism for 489 doing so (e.g., qvalues on Accept and similar request header fields), 490 that mechanism MAY be used to select preferred responses; of the 491 remainder, the most recent response (as determined by the Date header 492 field) is used, as per Section 4. 494 If no selected response is available, the cache cannot satisfy the 495 presented request. Typically, it is forwarded to the origin server 496 in a (possibly conditional; see Section 4.3) request. 498 4.2. Freshness 500 A fresh response is one whose age has not yet exceeded its freshness 501 lifetime. Conversely, a stale response is one where it has. 503 A response's freshness lifetime is the length of time between its 504 generation by the origin server and its expiration time. An explicit 505 expiration time is the time at which the origin server intends that a 506 stored response can no longer be used by a cache without further 507 validation, whereas a heuristic expiration time is assigned by a 508 cache when no explicit expiration time is available. 510 A response's age is the time that has passed since it was generated 511 by, or successfully validated with, the origin server. 513 When a response is "fresh" in the cache, it can be used to satisfy 514 subsequent requests without contacting the origin server, thereby 515 improving efficiency. 517 The primary mechanism for determining freshness is for an origin 518 server to provide an explicit expiration time in the future, using 519 either the Expires header field (Section 5.3) or the max-age response 520 directive (Section 5.2.2.8). Generally, origin servers will assign 521 future explicit expiration times to responses in the belief that the 522 representation is not likely to change in a semantically significant 523 way before the expiration time is reached. 525 If an origin server wishes to force a cache to validate every 526 request, it can assign an explicit expiration time in the past to 527 indicate that the response is already stale. Compliant caches will 528 normally validate a stale cached response before reusing it for 529 subsequent requests (see Section 4.2.4). 531 Since origin servers do not always provide explicit expiration times, 532 caches are also allowed to use a heuristic to determine an expiration 533 time under certain circumstances (see Section 4.2.2). 535 The calculation to determine if a response is fresh is: 537 response_is_fresh = (freshness_lifetime > current_age) 539 freshness_lifetime is defined in Section 4.2.1; current_age is 540 defined in Section 4.2.3. 542 Clients can send the max-age or min-fresh request directives 543 (Section 5.2.1) to constrain or relax freshness calculations for the 544 corresponding response. However, caches are not required to honor 545 them. 547 When calculating freshness, to avoid common problems in date parsing: 549 o Although all date formats are specified to be case-sensitive, a 550 cache recipient SHOULD match day, week, and time-zone names case- 551 insensitively. 553 o If a cache recipient's internal implementation of time has less 554 resolution than the value of an HTTP-date, the recipient MUST 555 internally represent a parsed Expires date as the nearest time 556 equal to or earlier than the received value. 558 o A cache recipient MUST NOT allow local time zones to influence the 559 calculation or comparison of an age or expiration time. 561 o A cache recipient SHOULD consider a date with a zone abbreviation 562 other than GMT or UTC to be invalid for calculating expiration. 564 Note that freshness applies only to cache operation; it cannot be 565 used to force a user agent to refresh its display or reload a 566 resource. See Section 6 for an explanation of the difference between 567 caches and history mechanisms. 569 4.2.1. Calculating Freshness Lifetime 571 A cache can calculate the freshness lifetime (denoted as 572 freshness_lifetime) of a response by using the first match of the 573 following: 575 o If the cache is shared and the s-maxage response directive 576 (Section 5.2.2.9) is present, use its value, or 578 o If the max-age response directive (Section 5.2.2.8) is present, 579 use its value, or 581 o If the Expires response header field (Section 5.3) is present, use 582 its value minus the value of the Date response header field, or 584 o Otherwise, no explicit expiration time is present in the response. 585 A heuristic freshness lifetime might be applicable; see 586 Section 4.2.2. 588 Note that this calculation is not vulnerable to clock skew, since all 589 of the information comes from the origin server. 591 When there is more than one value present for a given directive 592 (e.g., two Expires header fields, multiple Cache-Control: max-age 593 directives), the directive's value is considered invalid. Caches are 594 encouraged to consider responses that have invalid freshness 595 information to be stale. 597 4.2.2. Calculating Heuristic Freshness 599 Since origin servers do not always provide explicit expiration times, 600 a cache MAY assign a heuristic expiration time when an explicit time 601 is not specified, employing algorithms that use other header field 602 values (such as the Last-Modified time) to estimate a plausible 603 expiration time. This specification does not provide specific 604 algorithms, but does impose worst-case constraints on their results. 606 A cache MUST NOT use heuristics to determine freshness when an 607 explicit expiration time is present in the stored response. Because 608 of the requirements in Section 3, this means that, effectively, 609 heuristics can only be used on responses without explicit freshness 610 whose status codes are defined as cacheable by default (see 611 Section 9.1 of [Semantics]), and those responses without explicit 612 freshness that have been marked as explicitly cacheable (e.g., with a 613 "public" response directive). 615 If the response has a Last-Modified header field (Section 10.2.2 of 616 [Semantics]), caches are encouraged to use a heuristic expiration 617 value that is no more than some fraction of the interval since that 618 time. A typical setting of this fraction might be 10%. 620 Note: Section 13.9 of [RFC2616] prohibited caches from calculating 621 heuristic freshness for URIs with query components (i.e., those 622 containing '?'). In practice, this has not been widely 623 implemented. Therefore, origin servers are encouraged to send 624 explicit directives (e.g., Cache-Control: no-cache) if they wish 625 to preclude caching. 627 4.2.3. Calculating Age 629 The Age header field is used to convey an estimated age of the 630 response message when obtained from a cache. The Age field value is 631 the cache's estimate of the number of seconds since the response was 632 generated or validated by the origin server. In essence, the Age 633 value is the sum of the time that the response has been resident in 634 each of the caches along the path from the origin server, plus the 635 amount of time it has been in transit along network paths. 637 The following data is used for the age calculation: 639 age_value The term "age_value" denotes the value of the Age header 640 field (Section 5.1), in a form appropriate for arithmetic 641 operation; or 0, if not available. 643 date_value The term "date_value" denotes the value of the Date 644 header field, in a form appropriate for arithmetic operations. 645 See Section 10.1.1.2 of [Semantics] for the definition of the Date 646 header field, and for requirements regarding responses without it. 648 now The term "now" means "the current value of the clock at the host 649 performing the calculation". A host ought to use NTP ([RFC5905]) 650 or some similar protocol to synchronize its clocks to Coordinated 651 Universal Time. 653 request_time The current value of the clock at the host at the time 654 the request resulting in the stored response was made. 656 response_time The current value of the clock at the host at the time 657 the response was received. 659 A response's age can be calculated in two entirely independent ways: 661 1. the "apparent_age": response_time minus date_value, if the local 662 clock is reasonably well synchronized to the origin server's 663 clock. If the result is negative, the result is replaced by 664 zero. 666 2. the "corrected_age_value", if all of the caches along the 667 response path implement HTTP/1.1 or greater. A cache MUST 668 interpret this value relative to the time the request was 669 initiated, not the time that the response was received. 671 apparent_age = max(0, response_time - date_value); 673 response_delay = response_time - request_time; 674 corrected_age_value = age_value + response_delay; 676 These are combined as 678 corrected_initial_age = max(apparent_age, corrected_age_value); 680 unless the cache is confident in the value of the Age header field 681 (e.g., because there are no HTTP/1.0 hops in the Via header field), 682 in which case the corrected_age_value MAY be used as the 683 corrected_initial_age. 685 The current_age of a stored response can then be calculated by adding 686 the amount of time (in seconds) since the stored response was last 687 validated by the origin server to the corrected_initial_age. 689 resident_time = now - response_time; 690 current_age = corrected_initial_age + resident_time; 692 4.2.4. Serving Stale Responses 694 A "stale" response is one that either has explicit expiry information 695 or is allowed to have heuristic expiry calculated, but is not fresh 696 according to the calculations in Section 4.2. 698 A cache MUST NOT generate a stale response if it is prohibited by an 699 explicit in-protocol directive (e.g., by a "no-store" or "no-cache" 700 cache directive, a "must-revalidate" cache-response-directive, or an 701 applicable "s-maxage" or "proxy-revalidate" cache-response-directive; 702 see Section 5.2.2). 704 A cache MUST NOT generate a stale response unless it is disconnected 705 or doing so is explicitly permitted by the client or origin server 706 (e.g., by the max-stale request directive in Section 5.2.1, by 707 extension directives such as those defined in [RFC5861], or by 708 configuration in accordance with an out-of-band contract). 710 4.3. Validation 712 When a cache has one or more stored responses for a requested URI, 713 but cannot serve any of them (e.g., because they are not fresh, or 714 one cannot be selected; see Section 4.1), it can use the conditional 715 request mechanism Section 8.2 of [Semantics] in the forwarded request 716 to give the next inbound server an opportunity to select a valid 717 stored response to use, updating the stored metadata in the process, 718 or to replace the stored response(s) with a new response. This 719 process is known as "validating" or "revalidating" the stored 720 response. 722 4.3.1. Sending a Validation Request 724 When generating a conditional request for validation, a cache starts 725 with either a request it is attempting to satisfy, or -- if it is 726 initiating the request independently -- it synthesises a request 727 using a stored response by copying the method, request-target, and 728 request header fields used for identifying the secondary cache key 729 Section 4.1. 731 It then updates that request with one or more precondition header 732 fields. These contain validator metadata sourced from stored 733 response(s) that have the same cache key (both primary and secondary, 734 as applicable). 736 The precondition header fields are then compared by recipients to 737 determine whether any stored response is equivalent to a current 738 representation of the resource. 740 One such validator is the timestamp given in a Last-Modified header 741 field (Section 10.2.2 of [Semantics]), which can be used in an If- 742 Modified-Since header field for response validation, or in an If- 743 Unmodified-Since or If-Range header field for representation 744 selection (i.e., the client is referring specifically to a previously 745 obtained representation with that timestamp). 747 Another validator is the entity-tag given in an ETag header field 748 (Section 10.2.3 of [Semantics]). One or more entity-tags, indicating 749 one or more stored responses, can be used in an If-None-Match header 750 field for response validation, or in an If-Match or If-Range header 751 field for representation selection (i.e., the client is referring 752 specifically to one or more previously obtained representations with 753 the listed entity-tags). 755 4.3.2. Handling a Received Validation Request 757 Each client in the request chain may have its own cache, so it is 758 common for a cache at an intermediary to receive conditional requests 759 from other (outbound) caches. Likewise, some user agents make use of 760 conditional requests to limit data transfers to recently modified 761 representations or to complete the transfer of a partially retrieved 762 representation. 764 If a cache receives a request that can be satisfied by reusing one of 765 its stored 200 (OK) or 206 (Partial Content) responses, the cache 766 SHOULD evaluate any applicable conditional header field preconditions 767 received in that request with respect to the corresponding validators 768 contained within the selected response. A cache MUST NOT evaluate 769 conditional header fields that are only applicable to an origin 770 server, found in a request with semantics that cannot be satisfied 771 with a cached response, or applied to a target resource for which it 772 has no stored responses; such preconditions are likely intended for 773 some other (inbound) server. 775 The proper evaluation of conditional requests by a cache depends on 776 the received precondition header fields and their precedence, as 777 defined in Section 8.2.2 of [Semantics]. The If-Match and If- 778 Unmodified-Since conditional header fields are not applicable to a 779 cache. 781 A request containing an If-None-Match header field (Section 8.2.4 of 782 [Semantics]) indicates that the client wants to validate one or more 783 of its own stored responses in comparison to whichever stored 784 response is selected by the cache. If the field-value is "*", or if 785 the field-value is a list of entity-tags and at least one of them 786 matches the entity-tag of the selected stored response, a cache 787 recipient SHOULD generate a 304 (Not Modified) response (using the 788 metadata of the selected stored response) instead of sending that 789 stored response. 791 When a cache decides to revalidate its own stored responses for a 792 request that contains an If-None-Match list of entity-tags, the cache 793 MAY combine the received list with a list of entity-tags from its own 794 stored set of responses (fresh or stale) and send the union of the 795 two lists as a replacement If-None-Match header field value in the 796 forwarded request. If a stored response contains only partial 797 content, the cache MUST NOT include its entity-tag in the union 798 unless the request is for a range that would be fully satisfied by 799 that partial stored response. If the response to the forwarded 800 request is 304 (Not Modified) and has an ETag header field value with 801 an entity-tag that is not in the client's list, the cache MUST 802 generate a 200 (OK) response for the client by reusing its 803 corresponding stored response, as updated by the 304 response 804 metadata (Section 4.3.4). 806 If an If-None-Match header field is not present, a request containing 807 an If-Modified-Since header field (Section 8.2.5 of [Semantics]) 808 indicates that the client wants to validate one or more of its own 809 stored responses by modification date. A cache recipient SHOULD 810 generate a 304 (Not Modified) response (using the metadata of the 811 selected stored response) if one of the following cases is true: 1) 812 the selected stored response has a Last-Modified field-value that is 813 earlier than or equal to the conditional timestamp; 2) no Last- 814 Modified field is present in the selected stored response, but it has 815 a Date field-value that is earlier than or equal to the conditional 816 timestamp; or, 3) neither Last-Modified nor Date is present in the 817 selected stored response, but the cache recorded it as having been 818 received at a time earlier than or equal to the conditional 819 timestamp. 821 A cache that implements partial responses to range requests, as 822 defined in Section 8.3 of [Semantics], also needs to evaluate a 823 received If-Range header field (Section 8.2.7 of [Semantics]) with 824 respect to its selected stored response. 826 4.3.3. Handling a Validation Response 828 Cache handling of a response to a conditional request is dependent 829 upon its status code: 831 o A 304 (Not Modified) response status code indicates that the 832 stored response can be updated and reused; see Section 4.3.4. 834 o A full response (i.e., one with a payload body) indicates that 835 none of the stored responses nominated in the conditional request 836 is suitable. Instead, the cache MUST use the full response to 837 satisfy the request and MAY replace the stored response(s). 839 o However, if a cache receives a 5xx (Server Error) response while 840 attempting to validate a response, it can either forward this 841 response to the requesting client, or act as if the server failed 842 to respond. In the latter case, the cache MAY send a previously 843 stored response (see Section 4.2.4). 845 4.3.4. Freshening Stored Responses upon Validation 847 When a cache receives a 304 (Not Modified) response and already has 848 one or more stored 200 (OK) responses for the applicable cache key, 849 the cache needs to identify which (if any) are to be updated by the 850 new information provided, and then do so. 852 The stored response(s) to update are identified by using the first 853 match (if any) of the following: 855 o If the new response contains a strong validator (see 856 Section 10.2.1 of [Semantics]), then that strong validator 857 identifies the selected representation for update. All of the 858 stored responses with the same strong validator are identified for 859 update. If none of the stored responses contain the same strong 860 validator, then the cache MUST NOT use the new response to update 861 any stored responses. 863 o If the new response contains a weak validator and that validator 864 corresponds to one of the cache's stored responses, then the most 865 recent of those matching stored responses is identified for 866 update. 868 o If the new response does not include any form of validator (such 869 as in the case where a client generates an If-Modified-Since 870 request from a source other than the Last-Modified response header 871 field), and there is only one stored response, and that stored 872 response also lacks a validator, then that stored response is 873 identified for update. 875 For each stored response identified for update, the cache MUST use 876 the header fields provided in the 304 (Not Modified) response to 877 replace all instances of the corresponding header fields in the 878 stored response. 880 4.3.5. Freshening Responses with HEAD 882 A response to the HEAD method is identical to what an equivalent 883 request made with a GET would have been, except it lacks a body. 884 This property of HEAD responses can be used to invalidate or update a 885 cached GET response if the more efficient conditional GET request 886 mechanism is not available (due to no validators being present in the 887 stored response) or if transmission of the representation body is not 888 desired even if it has changed. 890 When a cache makes an inbound HEAD request for a given request target 891 and receives a 200 (OK) response, the cache SHOULD update or 892 invalidate each of its stored GET responses that could have been 893 selected for that request (see Section 4.1). 895 For each of the stored responses that could have been selected, if 896 the stored response and HEAD response have matching values for any 897 received validator fields (ETag and Last-Modified) and, if the HEAD 898 response has a Content-Length header field, the value of Content- 899 Length matches that of the stored response, the cache SHOULD update 900 the stored response as described below; otherwise, the cache SHOULD 901 consider the stored response to be stale. 903 If a cache updates a stored response with the metadata provided in a 904 HEAD response, the cache MUST use the header fields provided in the 905 HEAD response to replace all instances of the corresponding header 906 fields in the stored response and append new header fields to the 907 stored response's header section unless otherwise restricted by the 908 Cache-Control header field. 910 4.4. Invalidation 912 Because unsafe request methods (Section 7.2.1 of [Semantics]) such as 913 PUT, POST or DELETE have the potential for changing state on the 914 origin server, intervening caches can use them to keep their contents 915 up to date. 917 A cache MUST invalidate the effective Request URI (Section 5.3 of 918 [Semantics]) as well as the URI(s) in the Location and Content- 919 Location response header fields (if present) when a non-error status 920 code is received in response to an unsafe request method. 922 However, a cache MUST NOT invalidate a URI from a Location or 923 Content-Location response header field if the host part of that URI 924 differs from the host part in the effective request URI (Section 5.3 925 of [Semantics]). This helps prevent denial-of-service attacks. 927 A cache MUST invalidate the effective request URI (Section 5.3 of 928 [Semantics]) when it receives a non-error response to a request with 929 a method whose safety is unknown. 931 Here, a "non-error response" is one with a 2xx (Successful) or 3xx 932 (Redirection) status code. "Invalidate" means that the cache will 933 either remove all stored responses related to the effective request 934 URI or will mark these as "invalid" and in need of a mandatory 935 validation before they can be sent in response to a subsequent 936 request. 938 Note that this does not guarantee that all appropriate responses are 939 invalidated. For example, a state-changing request might invalidate 940 responses in the caches it travels through, but relevant responses 941 still might be stored in other caches that it has not. 943 5. Header Field Definitions 945 This section defines the syntax and semantics of HTTP header fields 946 related to caching. 948 +-------------------+-----------+--------------+ 949 | Header Field Name | Status | Reference | 950 +-------------------+-----------+--------------+ 951 | Age | standard | Section 5.1 | 952 | Cache-Control | standard | Section 5.2 | 953 | Expires | standard | Section 5.3 | 954 | Pragma | standard | Section 5.4 | 955 | Warning | obsoleted | Section 5.5 | 956 +-------------------+-----------+--------------+ 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 | stale-if-error | [RFC5861], Section 4 | 1025 | stale-while-revalidate | [RFC5861], Section 3 | 1026 +------------------------+-----------------------------------+ 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-04 1511 (work in progress), March 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-04 1535 (work in progress), March 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 = *( "," OWS ) cache-directive *( OWS "," [ OWS 1580 cache-directive ] ) 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 port = 1595 pseudonym = 1597 quoted-string = 1599 token = 1601 uri-host = 1603 Appendix B. Changes from RFC 7234 1605 The Warning response header was obsoleted. Much of the information 1606 supported by Warning could be gleaned by examining the response), and 1607 the remaining warn-codes -- although potentially useful -- were 1608 entirely advisory, and in practice were not added by caches or 1609 intermediaries. (Section 5.5) 1611 Appendix C. Change Log 1613 This section is to be removed before publishing as an RFC. 1615 C.1. Between RFC7234 and draft 00 1617 The changes were purely editorial: 1619 o Change boilerplate and abstract to indicate the "draft" status, 1620 and update references to ancestor specifications. 1622 o Remove version "1.1" from document title, indicating that this 1623 specification applies to all HTTP versions. 1625 o Adjust historical notes. 1627 o Update links to sibling specifications. 1629 o Replace sections listing changes from RFC 2616 by new empty 1630 sections referring to RFC 723x. 1632 o Remove acknowledgements specific to RFC 723x. 1634 o Move "Acknowledgements" to the very end and make them unnumbered. 1636 C.2. Since draft-ietf-httpbis-cache-00 1638 The changes are purely editorial: 1640 o Moved all extensibility tips, registration procedures, and 1641 registry tables from the IANA considerations to normative 1642 sections, reducing the IANA considerations to just instructions 1643 that will be removed prior to publication as an RFC. 1645 C.3. Since draft-ietf-httpbis-cache-01 1647 o Cite RFC 8126 instead of RFC 5226 () 1650 o In Section 5.4, misleading statement about the relation between 1651 Pragma and Cache-Control (, ) 1654 C.4. Since draft-ietf-httpbis-cache-02 1656 o In Section 3, explain that only final responses are cacheable 1657 () 1659 o In Section 5.2.2, clarify what responses various directives apply 1660 to () 1662 o In Section 4.3.1, clarify the source of validators in conditional 1663 requests () 1665 o Revise Section 6 to apply to more than just History Lists 1666 () 1668 o In Section 5.5, deprecated "Warning" header field 1669 () 1671 o In Section 3.2, remove a spurious note 1672 () 1674 C.5. Since draft-ietf-httpbis-cache-03 1676 o In Section 2, define what a disconnected cache is 1677 () 1679 o In Section 4, clarify language around how to select a response 1680 when more than one matches () 1683 o in Section 4.2.4, mention stale-while-revalidate and stale-if- 1684 error () 1686 o Remove requirements around cache request directives 1687 () 1689 o Deprecate Pragma () 1692 o In Section 3.2 and Section 5.2.2, note effect of some directives 1693 on authenticated requests () 1696 Index 1698 A 1699 Age header field 21 1700 age 11 1702 C 1703 Cache-Control header field 21 1704 cache 4 1705 cache entry 6 1706 cache key 6-7 1708 E 1709 Expires header field 29 1710 explicit expiration time 11 1712 F 1713 fresh 11 1714 freshness lifetime 11 1716 G 1717 Grammar 1718 Age 21 1719 ALPHA 5 1720 Cache-Control 22 1721 cache-directive 22 1722 CR 5 1723 CRLF 5 1724 CTL 5 1725 delta-seconds 6 1726 DIGIT 5 1727 DQUOTE 5 1728 Expires 29 1729 HEXDIG 5 1730 HTAB 5 1731 LF 5 1732 OCTET 5 1733 SP 5 1734 VCHAR 5 1736 H 1737 heuristic expiration time 11 1739 M 1740 max-age (cache directive) 22, 27 1741 max-stale (cache directive) 23 1742 min-fresh (cache directive) 23 1743 must-revalidate (cache directive) 24 1745 N 1746 no-cache (cache directive) 23, 25 1747 no-store (cache directive) 24, 26 1748 no-transform (cache directive) 24, 26 1750 O 1751 only-if-cached (cache directive) 24 1753 P 1754 Pragma header field 30 1755 private (cache directive) 26 1756 private cache 4 1757 proxy-revalidate (cache directive) 27 1758 public (cache directive) 26 1760 S 1761 s-maxage (cache directive) 27 1762 shared cache 4 1763 stale 11 1764 strong validator 19 1766 V 1767 validator 16 1769 W 1770 Warning header field 30 1772 Acknowledgments 1774 See Appendix "Acknowledgments" of [Semantics]. 1776 Authors' Addresses 1778 Roy T. Fielding (editor) 1779 Adobe 1780 345 Park Ave 1781 San Jose, CA 95110 1782 USA 1784 EMail: fielding@gbiv.com 1785 URI: https://roy.gbiv.com/ 1787 Mark Nottingham (editor) 1788 Fastly 1790 EMail: mnot@mnot.net 1791 URI: https://www.mnot.net/ 1793 Julian F. Reschke (editor) 1794 greenbytes GmbH 1795 Hafenweg 16 1796 Muenster, NW 48155 1797 Germany 1799 EMail: julian.reschke@greenbytes.de 1800 URI: https://greenbytes.de/tech/webdav/