<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" category="std" docName="draft-power-cdni-cache-control-metadata-00" updates="8006" ipr="trust200902" version="3">
  <!-- xml2rfc v2v3 conversion 3.16.0 -->
  <front>
    <title abbrev="CDNI Cache Control Metadata">CDNI Cache Control Metadata</title>
    <seriesInfo name="Internet-Draft" value="draft-power-cdni-cache-control-metadata-00"/>
    <author initials="W." surname="Power" fullname="Will Power">
      <organization>Lumen Technologies</organization>
      <address>
        <postal>
          <street/>
          <city/>
          <region/>
          <code/>
          <country>US</country>
        </postal>
        <email>wrpower@gmail.com</email>
      </address>
    </author>
    <author fullname="Glenn Goldstein" initials="G." surname="Goldstein">
      <organization>Lumen Technologies</organization>
      <address>
        <postal>
          <street/>
          <city/>
          <region/>
          <code/>
          <country>US</country>
        </postal>
        <email>glenng1215@gmail.com</email>
      </address>
    </author>
    <date/>
    <abstract>
      <t>
            This specification adds to the basic Cache Control metadata defined in RFC8006, providing Content Providers and uCDNs more fine-grained control over dCDN caching. Use cases include overriding or adjusting cache-control headers from the origin, bypassing caching altogether, or altering cache keys with dynamically generated values.
      </t>
    </abstract>
  </front>
  <middle>
    <section anchor="INTRODUCTION">
      <name>Introduction</name>
      <t>In addition to the cache control parameters currently specified by Cache object in <xref target="RFC8006"/>, Content Providers and uCDNs often need more fine-grained control over dCDN caching, including scenarios where it is desirable to override or adjust cache-control headers from the origin. </t>
      <t>These capabilities are required for commercial CDN and open caching use cases:</t>
      <t>Positive Cache Control - Allows the uCDN to specify internal caching policies for the dCDN and external caching policies advertised to clients of the dCDN, overriding any cache control policy set in the response from the uCDN.</t>
      <ol spacing="normal" type="1"><li>Positive Cache Control - Allows the uCDN to specify internal caching policies for the dCDN and external caching policies advertised to clients of the dCDN, overriding any cache control policy set in the response from the uCDN.</li>
        <li>Negative Cache Control - Allows the specification of caching policies based on error response codes received from the origin, allowing for fine-grained control of the downstream caching of error responses. For example, it may be desirable to cache error responses at the dCDN for a short period of time to prevent an overwhelmed origin service or uCDN from being flooded with requests.</li>
        <li>Cache Bypass Control - Allows content providers to bypass CDN caching when needed (typically for testing or performance benchmarking purposes).</li>
        <li>Stale Content Policies - Allows control over how the dCDN should process requests for stale content. For example, this policy allows the content provider to specify that stale content be served from cache for a specified time period while refreshes from the origin occur asynchronously. </li>
        <li>Dynamically Constructed Cache Keys - It is typical in advanced CDN configurations to generate cache keys that are dynamically constructed via lightweight processing of various properties of the HTTP request and/or response. As an example, an origin may specify a cache key as a value returned in a specific HTTP response header. The Metadata Expression Language is used to allow for such advanced cache key construction.</li>
      </ol>
    </section>
    <section anchor="MI.CachePolicy">
      <name>MI.CachePolicy</name>
      <t>CachePolicy is a new GenericMetadata object that allows for the uCDN to specify internal caching policies for the dCDN, as well as external caching policies advertised to clients of the dCDN (overriding any cache control policy set in the response from the uCDN).</t>
      <ul empty="true" spacing="normal">
        <li>
          <t>Property: internal  </t>
          <ul spacing="normal">
            <li>Description: Specifies the internal cache control policy to be used by the dCDN.</li>
            <li>Type: Number in seconds encoded as string (e.g. 5 is a five second cache ) and/or a list of Enumeration [as-is|no-cache|no-store]</li>
            <li>Mandatory-to-Specify: No. The default is to use the cache control policy specified in the response from the uCDN.</li>
          </ul>
        </li>
        <li>
          <t>Property: external  </t>
          <ul spacing="normal">
            <li>Description: Specifies the external cache control policy to be used by clients of the dCDN.</li>
            <li>Type: Number in seconds encoded as string (e.g. 5 is a five second cache ) and/or a list of Enumeration [as-is|no-cache|no-store]</li>
            <li>Mandatory-to-Specify: No. The default is to use the cache control policy specified in the response from the uCDN.</li>
          </ul>
        </li>
        <li>
          <t>Property: force-internal  </t>
          <ul spacing="normal">
            <li>Description: If set to True, the metadata interface cache policy defined in the MI.CachePolicy internal property value will override any cache control policy set in the response from the uCDN. If set to False, the MI.CachePolicy internal property value is only used if there is no cache control policy provided in the response from the uCDN.</li>
            <li>Type: Boolean</li>
            <li>Mandatory-to-Specify: No. The default is "False", which will apply the MI.CachePolicy  internal property value only if no policy is provided in the response from the uCDN.</li>
          </ul>
        </li>
        <li>
          <t>Property: force-external  </t>
          <ul spacing="normal">
            <li>Description: If set to True, the metadata interface cache policy defined in the MI.CachePolicy external property value will override any cache control policy set in the response from the uCDN. If set to False, the MI.CachePolicy external property value is only used if there is no cache control policy provided in the response from the uCDN.</li>
            <li>Type: Boolean</li>
            <li>Mandatory-to-Specify: No. The default is "False", which will apply the MI.CachePolicy  external property value only if no policy is provided in the response from the uCDN.</li>
          </ul>
        </li>
      </ul>
      <t>Example 1: An MI.CachePolicy that sets the internal cache control policy to five seconds. The external cache policy is set to 'no-cache', and both policies are forced:</t>
      <artwork><![CDATA[{
  "generic-metadata-type": "MI.CachePolicy",
  "generic-metadata-value": {
    "internal": "5",
    "external": "no-cache",
    "force-internal": "true",
    "force-external": "true"
  }
}
]]></artwork>
      <t> </t>
      <t>Example 2: An MI.CachePolicy that sets the internal cache control policy to "as-is" (keep the policy set in the response from the uCDN). The external cache policy is set to 'no-cache' and forced:</t>
      <artwork><![CDATA[{
  "generic-metadata-type": "MI.CachePolicy",
  "generic-metadata-value": {
    "internal": "as-is",
    "external": "no-cache",
    "force-external": "true"
  }
}
]]></artwork>
      <t>Example 3: An MI.CachePolicy in the context of the processing stages model that sets a caching policy only if the HTTP status code received from the origin is a 200. In this example, the internal cache control policy is set to five seconds. The external cache policy is set to 'no-cache'. Internal and external force flags are both set to ‘False’, indicating that the MI.CachePolicy only applies if there is no cache policy in the response from the uCDN.</t>
      <artwork><![CDATA[{
  "generic-metadata-type": "MI.ProcessingStages",
  "generic-metadata-value": {
    "origin-response": [
      {
        "match": {
          "expression": "resp.status == 200"
      },
      "stage-metadata": {
          "generic-metadata": [
            {
              "generic-metadata-type": "MI.CachePolicy",
              "generic-metadata-value": {
                "internal": "5",
                "external": "no-cache",
                "force-internal": "false",
                "force-external": "false"
              }
            }
          ]
        }
      }
    ]
  }
}
]]></artwork>
    </section>
    <section anchor="MI.NegativeCachePolicy">
      <name>MI.NegativeCachePolicy</name>
      <t>NegativeCachePolicy is a new GenericMetadata object that allows for the specification of caching policies based on response codes received from the origin.</t>
      <ul empty="true" spacing="normal">
        <li>
          <t>Property: error-codes  </t>
          <ul spacing="normal">
            <li>Description: Array of HTTP response status codes (See Sections 15.5 and 15.6 of <xref target="RFC9110"/>) , that if returned from the uCDN, will be cached using the cache policy defined by the cache-policy property.</li>
            <li>Type: Array of HTTP response status codes</li>
            <li>Values: Any HTTP status code from 100 to 599, or one of the special values  "4xx" or "5xx", where "xx" implies everything from 00 to 99. Note that use of 4xx would specify that 416 responses are cached.</li>
            <li>Mandatory-to-Specify: No. The default is to revert to <xref target="RFC8006"/> behavior.  An empty or unspecified list may function as a means to revoke a list inherited from an upper level configuration        </li>
          </ul>
        </li>
      </ul>
      <ul empty="true" spacing="normal">
        <li>
          <t>Property: cache-policy</t>
          <ul spacing="normal">
            <li>Description: MI.CachePolicy to apply to the HTTP response status codes returned by the uCDN.</li>
            <li>Mandatory-to-Specify: Yes</li>
          </ul>
        </li>
      </ul>
      <t>Example: A MI.NegativeCachePolicy that applies to HTTP error codes: "404", "503", "504" and sets the internal cache control policy to five seconds and external to 'no-cache'.</t>
      <artwork><![CDATA[{
  "generic-metadata-type": "MI.NegativeCachePolicy",
  "generic-metadata-value": {
    "error-codes": [ "404", "503", "504" ],
    "cache-policy": {
      "internal": "5",
      "external": "no-cache",
      "force-internal": "true",
      "force-external": "true"
    }
  }
}
]]></artwork>
    </section>
    <section anchor="MI.StaleContentCachePolicy">
      <name>MI.StaleContentCachePolicy</name>
      <t>MI.StaleContentCachePolicy is a new GenericMetadata object that allows the uCDN to specify the policy to use by a dCDN when responding with stale content.  For example, this policy allows the content provider to specify that stale content be served from cache for a specified time period while refreshes from the origin occur asynchronously.</t>
      <ul empty="true" spacing="normal">
        <li>
          <t>Property: stale-while-revalidating</t>
          <ul spacing="normal">
            <li>Description: Instructs the dCDN to serve a stale version of a resource while refreshing the resource with the uCDN. When set to "True", the dCDN will return a previously cached version of a resource while the resource is refreshed with the uCDN in the background. </li>
            <li>Type: Boolean</li>
            <li>Mandatory-to-Specify: No. The default is False, which waits for the uCDN to refresh a resource before responding to the client.   </li>
          </ul>
        </li>
        <li>
          <t>Property: stale-if-error</t>
          <ul spacing="normal">
            <li>Description: Instructs the dCDN to serve a stale version of a resource if any one of a specified set of HTTP status codes was received when trying to refresh the resource with the uCDN.  In this case, the dCDN will return a previously cached version of a resource instead of caching the error response. While this capability is typically used for well-understood HTTP error status codes, a list of any HTTP codes can be provided for maximum flexibility.</li>
            <li>Type: Array of HTTP response status codes</li>
            <li>Values: Any HTTP status code from 100 to 599, or one of the special values  "4xx" or "5xx", where "xx" implies everything from 00 to 99.</li>
            <li>Mandatory-to-Specify: No. The default is to not serve stale content.  An empty or unspecified list may function as a mean to revoke a list inherited from an upper level configuration </li>
          </ul>
        </li>
        <li>
          <t>Property: failed-refresh-ttl</t>
          <ul spacing="normal">
            <li>Description: Instructs the dCDN to serve a stale version of a resource for the number of seconds specified in failed-refresh-ttl before trying to revalidate the resource with the uCDN.  Use of failed-refresh-ttl allows the load to be reduced on the uCDN during times of system stress.</li>
            <li>Type: Integer</li>
            <li>Mandatory-to-Specify: No </li>
          </ul>
        </li>
      </ul>
      <t>Example 1: A MI.StaleContentCachePolicy where stale-while-revalidating is true, instructing the dCDN to respond with a stale cached version of the resource while it refreshes the resource with the uCDN in the background:</t>
      <artwork><![CDATA[{
  "generic-metadata-type": "MI.StaleContentCachePolicy",
  "generic-metadata-value": {
    "stale-while-revalidating": true
  }
}
]]></artwork>
      <t>Example 2: A MI.StaleContentCachePolicy where stale-if-error instructs the dCDN to use the stale cached resource if it receives an error of type 503 or 504 when trying to refresh the resource with the uCDN.</t>
      <t>failed-refresh-ttl instructs the dCDN to use a five second cache TTL on the resource that receives an error when refreshing from the uCDN. That is, after five seconds, the dCDN will attempt to refresh the resource with the uCDN.</t>
      <artwork><![CDATA[{
  "generic-metadata-type": "MI.StaleContentCachePolicy",
  "generic-metadata-value": {
    "stale-if-error": [ "503", "504" ],
    "failed-refresh-ttl": "5"
  }
}
]]></artwork>
      <t>Example 3: A MI.StaleContentCachePolicy where stale-while-revalidating is true, instructing the dCDN to respond with a stale cached version of the resource while it refreshes the resource with the uCDN in the background. </t>
      <t>stale-if-error instructs the dCDN to use the stale cached resource if it receives an error of type 404 or any 5xx status when trying to refresh the resource with the uCDN.</t>
      <t>failed-refresh-ttl instructs the dCDN to use a five second cache TTL on the resource that receives an error when refreshing from the uCDN. That is, after five seconds, the dCDN will attempt to refresh the resource with the uCDN.</t>
      <artwork><![CDATA[{
  "generic-metadata-type": "MI.StaleContentCachePolicy",
  "generic-metadata-value": {
    "stale-while-revalidating": "true",
      "stale-if-error": [ "404", "5xx" ],
      "failed-refresh-ttl": "5"
  }
}
]]></artwork>
    </section>
    <section anchor="MI.CacheBypassPolicy">
      <name>MI.CacheBypassPolicy</name>
      <t>CacheBypassPolicy is a new GenericMetadata object that allows a client request to be set as non-cacheable. It is expected that this feature will be used to allow clients to bypass cache when testing the uCDN fill path. Note: CacheBypassPolicy is typically used in conjunction with a path match or match expression on a header value or query parameter. Any content previously cached (by client requests that do not set CacheBypassPolicy) is not evicted. </t>
      <ul empty="true" spacing="normal">
        <li>
          <t>Property:  bypass-cache</t>
          <ul spacing="normal">
            <li>Description: A Boolean value that can activate the feature for a given client request.  It is expected that this feature will be used within ProcessingStages to allow a client request to be marked to bypass cache.</li>
            <li>Type: Boolean</li>
            <li>Mandatory-to-Specify: No. The default is False.</li>
          </ul>
        </li>
      </ul>
      <t>Example 1: A MI.CacheBypassPolicy with the client HTTP header of: CDN-BYPASS:  “True”:</t>
      <artwork><![CDATA[{
  "generic-metadata-type": "MI.ProcessingStages",
  "generic-metadata-value": {
    "client-request": [
      {
        "match": {
          "expression": "req.h.cdn-bypass == 'true'"
        },
        "stage-metadata": {
          "generic-metadata": [
            {
              "generic-metadata-type": "MI.CacheBypassPolicy",
              "generic-metadata-value": {
                "bypass-cache": "true"
              }
            }
          ]
        }
      }
    ]
  }
}
]]></artwork>
      <t>Example 2: A MI.CacheBypassPolicy that applies to all requests where the host header is bypass.example.com:</t>
      <artwork><![CDATA[{
  "generic-metadata-type": "MI.ProcessingStages",
  "generic-metadata-value": {
    "client-request": [
      {
        "match": {
          "expression": "req.h.host == 'bypass.example.com'"
      },
      "stage-metadata": {
          "generic-metadata": [
            {
              "generic-metadata-type": "MI.CacheBypassPolicy",
              "generic-metadata-value": {
                "bypass-cache": "true"
              }
            }
          ]
        }
      }
    ]
  }
}
]]></artwork>
    </section>
    <section anchor="MI.ComputedCacheKey">
      <name>MI.ComputedCacheKey</name>
      <t>It is typical in advanced CDN configurations to generate cache keys that are dynamically constructed via lightweight processing of various properties of the HTTP request and/or response. As an example, an origin may specify a cache key as a value returned in a specific HTTP response header.</t>
      <t>ComputedCacheKey is a new GenericMetadata object that allows for the specification of a cache key using the metadata expression language. Typical use cases would involve the construction of a cache key from one or more elements of the HTTP request. In cases where both the ComputedCacheKey and the Cache object are applied, the ComputedCacheKey will take precedence.</t>
      <ul empty="true" spacing="normal">
        <li>
          <t>Property: expression</t>
          <ul spacing="normal">
            <li>Description: The expression that specifies how the cache key shall be constructed.</li>
            <li>Type: String. An expression using <xref target="CDNI-MEL"/> to dynamically construct the cache key from elements of the HTTP request and/or response.</li>
            <li>Mandatory-to-Specify: Yes</li>
          </ul>
        </li>
      </ul>
      <t>Example, using a custom request header as the cache key instead of the URI path:</t>
      <artwork><![CDATA[{
  "generic-metadata-type": "MI.ComputedCacheKey",
  "generic-metadata-value": {
    "expression": "req.h.X-Cache-Key"
  }
}
]]></artwork>
    </section>
    <section anchor="CONCLUSION">
      <name>Conclusion</name>
      <t>This specification has defined a new set of Cache Control Metadata objects that meet the needs of Content Providers, CDNs, and Open Caching Systems. As the standard matures and gains wider adoption, it is expected that additions to this set of cache control policies will be required.</t>
    </section>
    <section anchor="Security">
      <name>Security Considerations</name>
      <t>
            The FCI and MI objects defined in the present document are
   transferred via the interfaces defined in CDNI <xref target="RFC8006"/>. <xref target="RFC8006"/>
   describes how to secure these interfaces, protecting the integrity,
   confidentiality and ensuring the authenticity of the dCDN and uCDN.
   The security provide by <xref target="RFC8006"/> should therefore address the above
   security concerns.
      </t>
    </section>
    <section anchor="IANA">
      <name>IANA Considerations</name>
      <section anchor="IANA.cdni.payload.types">
        <name>CDNI Payload Types</name>
        <t>
                    TBD.
        </t>
      </section>
    </section>
    <section anchor="Acknowledgements">
      <name>Acknowledgements</name>
      <t>
                The authors would like to express their gratitude to the members of the Streaming Video Technology Alliance <xref target="SVTA"/> Open Caching Working Group for their guidance / contribution / reviews ...)
      </t>
      <t>
                Particulary the following people contribute in one or other way to the content of this draft:
      </t>
      <ul empty="true" spacing="normal">
        <li>Guillaume Bichot - Broadpeak </li>
        <li>Pankaj Chaudhari - Disney Streaming Services</li>
        <li>Yoav Gressel - Qwilt</li>
        <li>Alfonso Siloniz - Telefonica</li>
        <li>Ben Rosenblum - Vecima</li>
      </ul>
    </section>
  </middle>
  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <reference anchor="RFC9110" target="https://www.rfc-editor.org/info/rfc9110" xml:base="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9110.xml">
          <front>
            <title>HTTP Semantics</title>
            <author fullname="R. Fielding" initials="R." role="editor" surname="Fielding"/>
            <author fullname="M. Nottingham" initials="M." role="editor" surname="Nottingham"/>
            <author fullname="J. Reschke" initials="J." role="editor" surname="Reschke"/>
            <date month="June" year="2022"/>
            <abstract>
              <t>The Hypertext Transfer Protocol (HTTP) is a stateless application-level protocol for distributed, collaborative, hypertext information systems. This document describes the overall architecture of HTTP, establishes common terminology, and defines aspects of the protocol that are shared by all versions. In this definition are core protocol elements, extensibility mechanisms, and the "http" and "https" Uniform Resource Identifier (URI) schemes.</t>
              <t>This document updates RFC 3864 and obsoletes RFCs 2818, 7231, 7232, 7233, 7235, 7538, 7615, 7694, and portions of 7230.</t>
            </abstract>
          </front>
          <seriesInfo name="STD" value="97"/>
          <seriesInfo name="RFC" value="9110"/>
          <seriesInfo name="DOI" value="10.17487/RFC9110"/>
        </reference>
        <reference anchor="RFC8006" target="https://www.rfc-editor.org/info/rfc8006" xml:base="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8006.xml">
          <front>
            <title>Content Delivery Network Interconnection (CDNI) Metadata</title>
            <author fullname="B. Niven-Jenkins" initials="B." surname="Niven-Jenkins"/>
            <author fullname="R. Murray" initials="R." surname="Murray"/>
            <author fullname="M. Caulfield" initials="M." surname="Caulfield"/>
            <author fullname="K. Ma" initials="K." surname="Ma"/>
            <date month="December" year="2016"/>
            <abstract>
              <t>The Content Delivery Network Interconnection (CDNI) Metadata interface enables interconnected Content Delivery Networks (CDNs) to exchange content distribution metadata in order to enable content acquisition and delivery.  The CDNI Metadata associated with a piece of content provides a downstream CDN with sufficient information for the downstream CDN to service content requests on behalf of an upstream CDN.  This document describes both a base set of CDNI Metadata and the protocol for exchanging that metadata.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="8006"/>
          <seriesInfo name="DOI" value="10.17487/RFC8006"/>
        </reference>
      </references>
      <references>
        <name>Informative References</name>
        <reference anchor="SVTA" target="https://www.svta.org">
          <front>
            <title>Streaming Video Technology Alliance Home Page</title>
            <author/>
            <date/>
          </front>
        </reference>
        <reference anchor="CDNI-MEL" target="">
          <front>
            <title>SVTA Open Caching - Configuration Interface Part 2a - Metadata Expression Language</title>
            <author initials="G." surname="Goldstein" fullname="Glenn Goldstein" role="editor">
              <organization>Lumen Technologies</organization>
            </author>
            <author initials="P." surname="Chaudhari" fullname="Pankaj Chaudhari">
              <organization>Disney Streaming Services</organization>
            </author>
            <author initials="W." surname="Power" fullname="William Power">
              <organization>Lumen Technologies</organization>
            </author>
            <author initials="Y." surname="Gressel" fullname="Yoav Gressel">
              <organization>Qwilt</organization>
            </author>
            <author initials="A." surname="Warshavsky" fullname="Arnon Warshavsky">
              <organization>Qwilt</organization>
            </author>
            <date day="2" month="July" year="2021"/>
          </front>
          <seriesInfo name="Version" value="2.0"/>
        </reference>
      </references>
    </references>
  </back>
</rfc>
