<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>Message Expiration</title>
  <abstract>This specification documents an historical protocol that was used to specify expiration dates for messages; this protocol has been deprecated in favor of XEP-0079: Advanced Message Processing.</abstract>
  &LEGALNOTICE;
  <number>0023</number>
  <status>Obsolete</status>
  <type>Historical</type>
  <sig>Standards</sig>
  <dependencies>
    <spec>XMPP Core</spec>
  </dependencies>
  <supersedes/>
  <supersededby>
    <spec>XEP-0079</spec>
  </supersededby>
  <shortname>x-expire</shortname>
  <schemaloc>
    <url>http://www.xmpp.org/schemas/x-expire.xsd</url>
  </schemaloc>
  &jer;
  <author>
    <firstname>DJ</firstname>
    <surname>Adams</surname>
    <email>dj.adams@pobox.com</email>
    <jid>dj@gnu.mine.nu</jid>
  </author>
  <author>
    <firstname>Harold</firstname>
    <surname>Gottschalk</surname>
    <email>heg@imissary.com</email>
    <jid>heg@imissary.com</jid>
  </author>
  <revision>
    <version>1.3</version>
    <date>2009-06-03</date>
    <initials>psa</initials>
    <remark><p>Per a vote of the XMPP Council, changed status to Obsolete.</p></remark>
  </revision>
  <revision>
    <version>1.2</version>
    <date>2004-10-18</date>
    <initials>psa</initials>
    <remark><p>Per a vote of the Jabber Council, changed status to Deprecated since message expiration functionality should be implemented via XEP-0079: Advanced Message Processing.</p></remark>
  </revision>
  <revision>
    <version>1.1</version>
    <date>2004-01-06</date>
    <initials>psa</initials>
    <remark><p>Added XML schema; added security, IANA, and XMPP Registrar considerations.</p></remark>
  </revision>
  <revision>
    <version>1.0</version>
    <date>2002-07-15</date>
    <initials>psa</initials>
    <remark><p>Changed status to Active.</p></remark>
  </revision>
  <revision>
    <version>0.9</version>
    <date>2002-03-19</date>
    <initials>dja</initials>
    <remark><p>Added remarks about client-end expiry.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2002-03-07</date>
    <initials>dja</initials>
    <remark><p>Initial draft.</p></remark>
  </revision>
</header>

<section1 topic='Introduction'>
  <p><em>Note Well: The protocol described herein has been deprecated by the &XSF;. The recommended protocol for implementing message expiration functionality is now &xep0079;.</em></p>
  <p>It is sometimes helpful to indicate that a piece of information has a finite useful life or time-to-live (TTL). In the context of instant messaging, the main use of a TTL is to indicate that a message must or should be used by or read by a certain time, usually because the message has meaning or purpose only within a finite amount of time. In normal usage, such a message should be discarded after the specified time has passed if it has not been used or read by that time.</p>
  <p>In Jabber, TTL functionality has been implemented informally using the jabber:x:expire namespace. Support for this namespace was added to the &jabberd; server as well as some clients and components in early 2001. Specifically, that support has involved the following two areas of responsibility:</p>
  <ul>
    <li>The sender of the message is responsible for attaching a jabber:x:expire extension to the XML stanza (usually a message).</li>
    <li>Mechanisms involved in the store-and-forward of such a stanza
<note>The best-known example of a mechanism that handles storing and forwarding of XML stanzas is the Jabber Session Manager (JSM) within current Jabber server implementations, specifically the mod_offline module. However, expiration of an XML stanza could also be handled by a Jabber client.</note>
en route to its intended recipient are responsible for checking the remaining time to live and expiring (discarding) the XML stanza if necessary.</li>
  </ul>
</section1>

<section1 topic='Specifying a TTL'>
  <p>An Endpoint can specify a TTL for an XML stanza that it wishes to send by attaching an &lt;x/&gt; extension qualified by the jabber:x:expire namespace. The extension contains no children, only a 'seconds' attribute that contains a value representing the stanza's TTL, in seconds.</p>

  <example caption='Specifying a 30-minute TTL for a message'>
SEND: &lt;message to='sabine@gnu.mine.nu' id='msg811'&gt;
        &lt;subject&gt;Eccles cakes!&lt;/subject&gt;
        &lt;body&gt;
          I've got some freshly made Eccles cakes here, come
          round for one before they all disappear!
        &lt;/body&gt;
        &lt;x xmlns='jabber:x:expire' seconds='1800'/&gt;
      &lt;/message&gt;
  </example>
</section1>

<section1 topic='Handling XML Stanzas with a TTL'>
  <p>Any mechanism that is involved in the storage, forwarding, and general handling of XML stanzas must check for the presence of such an extension and act accordingly, expiring (discarding) any stanzas that have exceeded their TTL lifetime.  The jabber:x:expire namespace allows for a further attribute inside the &lt;x/&gt; extension: 'stored'. Here, the mechanism can record a value representing when the stanza was committed to storage, so that when the stanza is eventually retrieved for forwarding to the intended recipient, the elapsed time of storage can be calculated. This is to prevent the stanza from being held in 'suspended animation'.</p>
  <p>Here we see what the original message looks like after the stanza has been committed to storage and the time of storage recorded:</p>
  <example caption='Recording a storage-time in the extension'>
SEND: &lt;message to='sabine@gnu.mine.nu' id='msg811'&gt;
        &lt;subject&gt;Eccles cakes!&lt;/subject&gt;
        &lt;body&gt;
          I've got some freshly made Eccles cakes here, come
          round for one before they all disappear!
        &lt;/body&gt;
        &lt;x xmlns='jabber:x:expire'
           seconds='1800'
           stored='912830221'/&gt;
      &lt;/message&gt;
  </example>
  <p>When Sabine attempts to retrieve her offline messages, the store-and-forward mechanism (e.g., mod_offline) compares the current time against the stored attribute. If the 1800 seconds have passed, the mechanism should simply drop the message, without notifying either the sender or the intended recipient. No Eccles cakes for Sabine!</p>
<section2 topic='Usage in client space'>
  <p>Although current usage of jabber:x:expire is most commonly seen in server implementations to address any TTL requirements of stored messages, Jabber clients can also be seen as handlers of messages that may contain expiration extension information. If a message is received by a Jabber client, and not immediately displayed to the user, the client must check for TTL information and expire the message (rather than display it to the user) if appropriate.</p>
</section2>
</section1>

<section1 topic='Security Considerations'>
  <p>There are no security features or concerns related to this proposal.</p>
</section1>
<section1 topic='IANA Considerations'>
  <p>This document requires no interaction with &IANA;.</p>
</section1>
<section1 topic='XMPP Registrar Considerations'>
  <p>No action on the part of the &REGISTRAR; is necessary as a result of this document, since 'jabber:x:expire' is already a registered protocol namespace.</p>
</section1>

<section1 topic='XML Schema'>
  <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='jabber:x:expire'
    xmlns='jabber:x:expire'
    elementFormDefault='qualified'>

  <xs:annotation>
    <xs:documentation>
      The protocol documented by this schema is defined in
      XEP-0023: http://www.xmpp.org/extensions/xep-0023.html
    </xs:documentation>
  </xs:annotation>

  <xs:element name='x'>
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base='empty'>
          <xs:attribute name='seconds' type='xs:unsignedLong' use='required'/>
          <xs:attribute name='stored' type='xs:unsignedLong' use='optional'/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name='empty'>
    <xs:restriction base='xs:string'>
      <xs:enumeration value=''/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>
    ]]></code>
</section1>

<section1 topic='Open Issues'>
  <ol>
    <li>The jabber:x:expire namespace is processed only for delayed messages and only by servers and subsystems which support this informational draft. Therefore it is possible or even likely that a TTL will not be properly handled from the user perspective.</li>
    <li>A physical, time-based TTL is not implemented by this document, and would not be possible across systems without synchronized time.</li>
  </ol>
</section1>

</xep>
