If I mount a static directory in CherryPy, like so:
wwwroot_config = { '/':
{ 'tools.staticdir.on': True,
'tools.staticdir.dir': '/path/to/dir' } }
cherrypy.tree.mount(root, '/', config = wwwroot_config)
File downloads from that directory go pretty slowly.
However, if I create my own WSGI app...
self.wsgi_server = wsgiserver.CherryPyWSGIServer((self.bindaddress, self.port), self.download_file, numthreads = 1)
With self.download_file containing, basically:
return serve_file(theFile, "application/x-download", "attachment", os.path.basename(theFile), debug = True)
I get speeds that are 4-5x faster.
However, this way is not as flexible because the headers that serve_file adds to the request (such as the range headers and content length) don't get returned in the response - I have to do it myself.
Is there anything I can do to make the first way faster?