ltonetwork / mongodb-rest

JSON REST server for MongoDB (using node.js)
MIT License
405 stars 143 forks source link

Collection Cache and Access-Control-Allow-Origin #15

Closed muddydixon closed 13 years ago

muddydixon commented 13 years ago
  1. add "Access-Control-Allow-Origin" setting to server.js
  2. collection cache to lib/rest.js
<1> I always use mongodb-rest in cross-domain (or different port from web server), so I add Access-Control-Allow-Origin fields in config. If the field is set, app.use a middleware if(config['access-contorol-allow-origin']){ app.use(function(req, res, next){ res.header('access-contorol-allow-origin', config['access-contorol-allow-origin']); next(); }); } <2> I add collection cache and I executed benchmark. like that $ for j in 1 2 3 4 5; do time for i in {1..1000}; do wget -q http://localhost:3000/mydb/mycol/ -O /dev/null ; done; done = enable cache = real 0m14.848s real 0m14.015s real 0m15.896s real 0m14.367s real 0m15.940s = disable cache = real 0m17.740s real 0m17.694s real 0m17.361s real 0m18.010s real 0m17.511s
benjamine commented 13 years ago

ops, muddy, I did a pull request a few days ago with Access-Control-Allow-Origin: https://github.com/tdegrunt/mongodb-rest/pull/14

muddydixon commented 13 years ago

I confirmed the change. So nice!

tdegrunt commented 13 years ago

benjamine's pull request has since been merged, perhaps we could still include the caching? @muddydixon: Would you be prepared to isolate those from your pull request, or perhaps create a new pull request with just those changes in?

muddydixon commented 13 years ago

Oh, I'll create new pull request including only collection cache.