title: Fetching an image and associated metadata with an AJAX request
body: <p>I have a somewhat expensive server-side operation that produces an image and some associated text metadata about that image. My web page will display both.</p>
  
  <p>The image and its data are fetched with AJAX calls. On the server side, it is possible to produce the image and the metadata at the same time. How can I transfer (and display) both the image and the data with one AJAX call?</p>
  
  <p>(The problem with making two calls is that the expensive server-side operation ends up happening twice when it doesn't have to.)</p>
  
  <p>Edit:
  To clarify, the image is drawn dynamically in a servlet. If it has a separate URL from the metadata, then two requests are required, and the expensive operation happens twice. I don't want to write my own caching in the servlet, since using a caching proxy and max-age is otherwise working great.</p>