No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0150.xml 18KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Use of Entity Tags in XMPP Extensions</title>
  10. <abstract>This document defines best practices for the use of Entity Tags in XMPP extensions.</abstract>
  12. <number>0150</number>
  13. <status>Deferred</status>
  14. <type>Informational</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>RFC 2616</spec>
  20. <spec>XEP-0131</spec>
  21. </dependencies>
  22. <supersedes/>
  23. <supersededby/>
  24. <shortname>N/A</shortname>
  25. &hildjj;
  26. &stpeter;
  27. <revision>
  28. <version>0.2</version>
  29. <date>2005-08-09</date>
  30. <initials>psa</initials>
  31. <remark><p>Added security considerations.</p></remark>
  32. </revision>
  33. <revision>
  34. <version>0.1</version>
  35. <date>2005-06-02</date>
  36. <initials>psa</initials>
  37. <remark><p>Initial version.</p></remark>
  38. </revision>
  39. <revision>
  40. <version>0.0.1</version>
  41. <date>2005-05-26</date>
  42. <initials>psa/jjh</initials>
  43. <remark><p>First draft.</p></remark>
  44. </revision>
  45. </header>
  46. <section1 topic='Introduction' anchor='intro'>
  47. <p>When an XMPP instant messaging client connects to its server, it typically retrieves a great deal of information, such as a user's roster, privacy lists, and service discovery information. However, this information may not have changed since the client last retrieved the data. In order to improve client start-up time or conserve bandwidth in certain environments, it would be desirable if the client could cache the information and retrieve it only if it has changed.</p>
  48. <p>Such a mechanism exists as part of &rfc2616; in the form of the Entity Tags, which are included in the ETag and If-None-Match headers used for HTTP caching. Since &xep0131; enables an XMPP entity to communicate any HTTP header, it should be possible to re-use existing Entity Tag semantics for caching information sent over an XMPP network. This document defines best practices for such functionality, which could be used between any two XMPP entities that support SHIM headers (though it is envisioned to be most useful for clients that retrieve information from servers and services).</p>
  49. </section1>
  50. <section1 topic='Requirements' anchor='reqs'>
  51. <p>This document addresses the following requirements:</p>
  52. <ol>
  53. <li>Enable caching of information sent over an XMPP network (i.e., retrieval of information only if it has changed since it was last retrieved).</li>
  54. <li>Re-use existing HTTP Entity Tag semantics.</li>
  55. </ol>
  56. </section1>
  57. <section1 topic='Concepts and Approach' anchor='approach'>
  58. <p>In HTTP, an "entity" is the information transferred as the payload of a request or response, and an "Entity Tag" is an opaque string that uniquely identifies that payload. For example, when an HTTP server sends an entity in an HTTP response, it can include an ETag header that identifies the payload as cacheable, and the client can cache that entity; in future requests, the client can include the same value in an If-None-Match header and the server will either return an HTTP 304 ("Not Modified") error if the entity has not changed or return the entity in the HTTP response if it has changed. (Note: For information about the semantics of Entity Tags, the ETag header, and the If-None-Match header, refer to Sections 3.11, 14.19, and 14.26 respectively of <cite>RFC 2616</cite>.)</p>
  59. <p>The basic concept behind XMPP Entity Tag use is semantically equivalent to the use in HTTP (although we use the term "data object" to refer to the payload); this is made possible by a straightforward application of SHIM headers as specified in <cite>XEP-0131</cite>. In the context of an IQ request-response interaction, the responding entity will include an ETag SHIM header in its IQ response (indicating that the data object can be cached), the requesting entity will include that identical value in an If-None-Match SHIM header when it queries the server for the same data object, and the responding entity will return either an IQ result with the changed data object or an IQ error indicating that the data object has not changed.</p>
  60. <p>Here is an example of such a request-response flow (the example is that of roster retrieval):</p>
  61. <example caption='Client Requests Roster'><![CDATA[
  62. <iq type='get'
  63. from=''
  64. id='roster1'>
  65. <query xmlns='jabber:iq:roster'/>
  66. </iq>
  67. ]]></example>
  68. <example caption='Server Returns Roster Including ETag Header'><![CDATA[
  69. <iq type='result'
  70. to=''
  71. id='roster1'>
  72. <query xmlns='jabber:iq:roster'>
  73. <item jid='' name='Romeo'>
  74. <group>Friends</group>
  75. </item>
  76. <item jid='' name='Nurse'>
  77. <group>Servants</group>
  78. </item>
  79. <headers xmlns=''>
  80. <header name='ETag'>some-long-opaque-string</header>
  81. </headers>
  82. </query>
  83. </iq>
  84. ]]></example>
  85. <example caption='Client Requests Roster Including If-None-Match Header'><![CDATA[
  86. <iq type='get'
  87. from=''
  88. id='roster2'>
  89. <query xmlns='jabber:iq:roster'>
  90. <headers xmlns=''>
  91. <header name='If-None-Match'>some-long-opaque-string</header>
  92. </headers>
  93. </query>
  94. </iq>
  95. ]]></example>
  96. <p>If the responding entity does not understand the If-None-Match header or does not handle Entity Tags for the namespace in the request, it MUST ignore the header and return whatever information it would have returned if the header had not been present.</p>
  97. <p>If the responding entity determines that the requested information has not changed since it was last retrieved by the requesting entity, then it MUST return a &lt;not-modified/&gt; error corresponding to the HTTP 304 error returned by HTTP entities that support the ETag header:</p>
  98. <example caption='Responding Entity Returns Not Modified Error'><![CDATA[
  99. <iq type='error'
  100. to=''
  101. id='roster2'>
  102. <query xmlns='jabber:iq:roster'>
  103. <headers xmlns=''>
  104. <header name='If-None-Match'>some-long-opaque-string</header>
  105. </headers>
  106. </query>
  107. <error code='304' type='modify'>
  108. <not-modified xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  109. </error>
  110. </iq>
  111. ]]></example>
  112. <p>Note: The &lt;not-modified/&gt; error condition is not specified as a stanza error condition in &rfc3920; and an error code of 304 was not included in the older Jabber error codes (see &xep0086;). However, the &lt;not-modified/&gt; error condition is included in &xmppcore;.</p>
  113. <p>Note: In HTTP, an Entity Tag may be either "strong" or "weak" (see Section 13.3.3 of <cite>RFC 2616</cite>); Entity Tags as used in XMPP extensions MUST be considered strong rather than weak.</p>
  114. <p>Note: The ETag and If-None-Match headers SHOULD be used only in &IQ; stanzas, although they MAY be used in &MESSAGE; stanza interactions if IQ request-response semantics are not appropriate, for example in &xep0072; and in certain applications that use &xep0004;.</p>
  115. </section1>
  116. <section1 topic='Use Cases' anchor='usecases'>
  117. <section2 topic='Caching and Retrieving Rosters' anchor='roster'>
  118. <p>As specified in &xmppim;, an XMPP instant messaging client will typically store its "roster" (contact list) on the server so that any connecting client for that account can retrieve the roster at will. Since <cite>RFC 6121</cite> defines no upper limit on the number of items allowed in the roster, it is possible for a roster to become quite large (e.g., there are known cases of rosters with more than 1,000 items). Therefore a server may support Entity Tag functionality with regard to roster management. The process is as follows.</p>
  119. <p>First, the client requests its roster:</p>
  120. <example caption='Client Requests Roster'><![CDATA[
  121. <iq type='get'
  122. from=''
  123. id='roster1'>
  124. <query xmlns='jabber:iq:roster'/>
  125. </iq>
  126. ]]></example>
  127. <p>If the server supports Entity Tag functionality for rosters, it SHOULD include an ETag SHIM header in its response (although it MAY decide not to include the header if the roster is deemed to be not worth caching because it is so small):</p>
  128. <example caption='Server Returns Roster Including ETag Header'><![CDATA[
  129. <iq type='result'
  130. to=''
  131. id='roster1'>
  132. <query xmlns='jabber:iq:roster'>
  133. <item jid='' name='Romeo'>
  134. <group>Friends</group>
  135. </item>
  136. <item jid='' name='Nurse'>
  137. <group>Servants</group>
  138. </item>
  139. <headers xmlns=''>
  140. <header name='ETag'>some-long-opaque-string</header>
  141. </headers>
  142. </query>
  143. </iq>
  144. ]]></example>
  145. <p>The client would then cache that roster and associate the included Entity Tag with that cached copy. In order to subsequently retrieve the roster, the client would include the last known Entity Tag value with the request in an If-None-Match SHIM header:</p>
  146. <example caption='Client Requests Roster, Including If-None-Match Header'><![CDATA[
  147. <iq type='get'
  148. from=''
  149. id='roster2'>
  150. <query xmlns='jabber:iq:roster'>
  151. <headers xmlns=''>
  152. <header name='If-None-Match'>some-long-opaque-string</header>
  153. </headers>
  154. </query>
  155. </iq>
  156. ]]></example>
  157. <p>If the roster did not change since the client last retrieved the roster and the server supports Entity Tags for the 'jabber:iq:roster' namespace, the server MUST return a &lt;not-modified/&gt; error:</p>
  158. <example caption='Server Returns Not Modified Error'><![CDATA[
  159. <iq type='error'
  160. to=''
  161. id='roster2'>
  162. <query xmlns='jabber:iq:roster'>
  163. <headers xmlns=''>
  164. <header name='ETag'>some-long-opaque-string</header>
  165. </headers>
  166. </query>
  167. <error code='304' type='modify'>
  168. <not-modified xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  169. </error>
  170. </iq>
  171. ]]></example>
  172. <p>If the roster has changed, the provided Entity Tag value is not valid, or the server does not support Entity Tags, it MUST return the roster as if the If-None-Match header was not included:</p>
  173. <example caption='Server Returns Roster'><![CDATA[
  174. <iq type='result'
  175. to=''
  176. id='roster2'>
  177. <query xmlns='jabber:iq:roster'>
  178. <item jid='' name='Romeo'>
  179. <group>Friends</group>
  180. </item>
  181. <item jid='' name='Nurse'>
  182. <group>Servants</group>
  183. </item>
  184. <headers xmlns=''>
  185. <header name='ETag'>some-new-opaque-string</header>
  186. </headers>
  187. </query>
  188. </iq>
  189. ]]></example>
  190. </section2>
  191. <section2 topic='Caching and Retrieving Privacy Lists' anchor='privacy'>
  192. <p>The payloads exchanged in the &xep0016; protocol can also be quite large. Therefore a server might want to support Entity Tags in the context of privacy list management. The process is as follows.</p>
  193. <p>First, a client requests its privacy lists:</p>
  194. <example caption='Client Requests Privacy List'><![CDATA[
  195. <iq type='get'
  196. from=''
  197. id='getlist1'>
  198. <query xmlns='jabber:iq:privacy'>
  199. <list name='special'/>
  200. </query>
  201. </iq>
  202. ]]></example>
  203. <p>The server returns the list and includes an Entity Tag in an ETag SHIM header.</p>
  204. <example caption='Server Returns Privacy List Including ETag Header'><![CDATA[
  205. <iq type='result'
  206. to=''
  207. id='getlist1'>
  208. <query xmlns='jabber:iq:privacy'>
  209. <list name='special'>
  210. <item type='jid'
  211. value=''
  212. action='allow'
  213. order='6'/>
  214. <item type='jid'
  215. value=''
  216. action='allow'
  217. order='7'/>
  218. <item type='jid'
  219. value=''
  220. action='allow'
  221. order='42'/>
  222. <item action='deny' order='666'/>
  223. </list>
  224. <headers xmlns=''>
  225. <header name='ETag'>some-long-opaque-string</header>
  226. </headers>
  227. </query>
  228. </iq>
  229. ]]></example>
  230. <p>Later, the client requests the same privacy list again and includes the provided Entity Tag in an If-None-Match SHIM header:</p>
  231. <example caption='Client Requests Privacy List Including If-None-Match Header'><![CDATA[
  232. <iq type='get'
  233. from=''
  234. id='getlist2'>
  235. <query xmlns='jabber:iq:privacy'>
  236. <list name='special'/>
  237. <headers xmlns=''>
  238. <header name='If-None-Match'>some-long-opaque-string</header>
  239. </headers>
  240. </query>
  241. </iq>
  242. ]]></example>
  243. <p>If the privacy list did not change since the client last retrieved it and the server supports Entity Tags for the 'jabber:iq:privacy' namespace, the server MUST return a &lt;not-modified/&gt; error:</p>
  244. <example caption='Server Returns Not Modified Error'><![CDATA[
  245. <iq type='error'
  246. to=''
  247. id='getlist2'>
  248. <query xmlns='jabber:iq:privacy'>
  249. <list name='special'/>
  250. <headers xmlns=''>
  251. <header name='ETag'>some-long-opaque-string</header>
  252. </headers>
  253. </query>
  254. <error code='304' type='modify'>
  255. <not-modified xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  256. </error>
  257. </iq>
  258. ]]></example>
  259. <p>If the privacy list has changed, the provided Entity Tag value is not valid, or the server does not support Entity Tags, it MUST return the privacy list as if the If-None-Match header was not included:</p>
  260. <example caption='Server Returns Privacy List'><![CDATA[
  261. <iq type='result'
  262. to=''
  263. id='getlist2'>
  264. <query xmlns='jabber:iq:privacy'>
  265. <list name='special'>
  266. <item type='jid'
  267. value=''
  268. action='allow'
  269. order='6'/>
  270. <item type='jid'
  271. value=''
  272. action='allow'
  273. order='7'/>
  274. <item type='jid'
  275. value=''
  276. action='allow'
  277. order='42'/>
  278. <item action='deny' order='666'/>
  279. </list>
  280. <headers xmlns=''>
  281. <header name='ETag'>some-new-opaque-string</header>
  282. </headers>
  283. </query>
  284. </iq>
  285. ]]></example>
  286. </section2>
  287. <section2 topic='Discovering Support' anchor='disco'>
  288. <p><cite>XEP-0131</cite> specifies how support for a particular SHIM header can be explicitly determined using &xep0030;. To review, the protocol flow between a client and a server is as follows:</p>
  289. <example caption='Client Queries Server Regarding SHIM Header Support'><![CDATA[
  290. <iq from=''
  291. to=''
  292. id='header1'>
  293. <query xmlns=''
  294. node=''/>
  295. </iq>
  296. ]]></example>
  297. <example caption='Server Communicates Supported SHIM Headers'><![CDATA[
  298. <iq from=''
  299. to=''
  300. id='header1'>
  301. <query xmlns=''
  302. node=''>
  303. ...
  304. <feature var=''/>
  305. <feature var=''/>
  306. ...
  307. </query>
  308. </iq>
  309. ]]></example>
  310. <p>The client now knows that the server supports the ETag and If-None-Match SHIM headers and can proceed accordingly.</p>
  311. <p>Note: If an XMPP entity supports Entity Tags as specified herein, it MUST at a minimum support both the ETag and If-None-Match SHIM headers.</p>
  312. <p>Note: Even if an entity supports the ETag and If-None-Match SHIM headers, it is not required to support Entity Tag functionality for all namespaces. For example, a server could support Entity Tags only for rosters and privacy lists but not for the 'jabber:iq:last' or 'jabber:iq:version' namespaces. Similarly, a &xep0045; service could support Entity Tags only for room lists (retrieved via a "disco#items" request) but not for other requests. As noted, if an entity does not support Entity Tags for a given namespace or request, it SHOULD proceed as if the ETag or If-None-Match SHIM header had not been included in the request.</p>
  313. <p>Optionally, an entity MAY communicate the namespaces for which it supports Entity Tag functionality by listing those namespaces in its response to a "disco#info" request sent to a node of "":</p>
  314. <example caption='Client Queries Server Regarding Supported Entity Tag Namespaces'><![CDATA[
  315. <iq from=''
  316. to=''
  317. id='header1'>
  318. <query xmlns=''
  319. node=''/>
  320. </iq>
  321. ]]></example>
  322. <example caption='Server Communicates Supported Entity Tag Namespaces'><![CDATA[
  323. <iq from=''
  324. to=''
  325. id='header1'>
  326. <query xmlns=''
  327. node=''>
  328. ...
  329. <feature var='jabber:iq:roster'/>
  330. <feature var='jabber:iq:privacy'/>
  331. ...
  332. </query>
  333. </iq>
  334. ]]></example>
  335. <p>Alternatively, as shown above and as used in HTTP, the requesting entity MAY implicitly discover that Entity Tag functionality is supported with regard to a given response entity type if the responding entity includes an ETag SHIM header in its response.</p>
  336. </section2>
  337. </section1>
  338. <section1 topic='Security Considerations' anchor='security'>
  339. <p>If a malicious entity gains access to a user's credentials or is able to masquerade as another entity on the network (e.g., as a man in the middle), it could force retrieval of information before it has changed. However, such access would compromise communications in a more serious fashion and corruption of the Entity Tags functionality is insignificant in comparison.</p>
  340. </section1>
  341. <section1 topic='IANA Considerations' anchor='iana'>
  342. <p>This proposal requires no interaction with &IANA;.</p>
  343. </section1>
  344. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  345. <p>This proposal requires no interaction with the &REGISTRAR;.</p>
  346. </section1>
  347. <section1 topic='XML Schema' anchor='schema'>
  348. <p>This document describes best practices for use of XEP-0131 and therefore does not require a dedicated schema.</p>
  349. </section1>
  350. <section1 topic='Open Issues' anchor='issues'>
  351. <p>Is the ETag tied to a bare JID or full JID?</p>
  352. </section1>
  353. </xep>