Emit 'endHead' before 'newResponse'

To give those listening for endHead events a change to modify the head
earlier.
Fix MongoDb client

Now works with cache.js.