fix(XML): Improve XML loading/parsing performance (refs #4881)

- Cache DOMDocuments from XML files for reuse.
- Prevent corruption of XML files (e.g. when in low disk space
  conditions) by safely writing them with a transaction.
fix(net): Improve network requests performance (refs #4881)

- Reduce network bandwidth usage by using "Accept-Encoding" headers for
  compressed responses.
- Reduce number of HTTP requests by caching the responses' files.
- Move all net/www related code into distinct WWW\UserAgent class.