When size does matter: shrink your XML

During the last weeks we’ve fixed bugs, added and removed features, tweaked the UI and Jan worked on the design. In short: a lot of work!
Since we are following the rules of optimisation we did not tackle performance so far. After benchmarking we decided that it is time to shrink the size of the XML we send back and forth between client and server. Here are the steps we followed:

  1. Remove unused content. Easy, I know. But for some models we still relied on the default to_xml() method which includes about every attribute. Use the :only or :exclude options to remove unused elements.
  2. Flatten hierarchy. Remove unused nested elements.
  3. Move child elements to attributes. This works as long as the child elements do not represent complex/nested data
  4. Shorten names of elements and attributes.
  5. And, of course, we added mod_deflate to our Apache


That’s it. Following these simple steps significantly reduced the amount of transferred data, server load was decreased and - most important - the client responds faster to user interaction.


About this entry