var crypto = require('crypto'), generateFeed = require('./generate-feed'), feedCache = {}; module.exports.getXML = function getFeedXml(path, data) { var dataHash = crypto.createHash('md5').update(JSON.stringify(data)).digest('hex'); if (!feedCache[path] || feedCache[path].hash !== dataHash) { // We need to regenerate feedCache[path] = { hash: dataHash, xml: generateFeed(data) }; } return feedCache[path].xml; };