send
send copied to clipboard
don't read to file when the browser cache is valid
@amitport try https://github.com/koajs/conditional-get
@coderhaoxin, wouldn't conditional-get still cause the file to be read?
So although the client wouldn't wait for the server to read the file, the server will become slow when trying to process many requests in parallel
Personally, I have CDN for production.
/cc @jonathanong
yes, I try not to serve files directly on my node.js server. they should be served via CDN.
However, I understand how the developer UX for this modular is subpar. When TJ and I were making this, I wasn't too fond of the decision to not bake the caching logic into the middleware as, as you said, it creates a file descriptor. but it does make the code simpler.
IMO it's up to the community—I don't mind baking in conditional get logic here or not. I care more that coverage dropped :)
@amitport can you add some tests for this ? :)
@coderhaoxin no problem, I will add this behind an optional flag and add docs+tests in a few days.
Regading CDN, IMHO, koa should provide something reasonable out-of-the-box and this is just common sense http, not some crazy optimization.
+1 on this