We're using Testem to serve a bunch of HTML files (templates). Under the covers Testem uses the "res.sendfile" method of Express to send the static file back to the client. On Mac machines this is very fast - 1-2 ms per file according to the Chrome network trace. On an Ubuntu machine, however, it takes 39ms.
This is on the latest stable Node - 0.10.29. Testem is using Express 3.1.
Any suggestions on what might cause this or how I can diagnose it further?
I typically serve static files directly using:
middleware. Your static files would be stored in
This will allow you to access
/<app-path>/public/some.html
at:If you put
file.html
in/<app-path>/public/html/
, the following would resolve:If the desired result is to have clean urls without extensions, then my suggestion will not do. However, if you don't mind file extensions within urls, the static middleware should reduce request times, maybe even dramatically. Also, maybe a templating engine like
dust
orjade
may help? It would allow you to use theres.render
fn.The thing is, I have seen request times increase when using:
Because express will pass that through its regex path resolution middleware before serving the file. If you have a ton of routes, that may also be slowing down request times.
Hope that helps!