send icon indicating copy to clipboard operation
send copied to clipboard

don't read to file when the browser cache is valid

Open amitport opened this issue 8 years ago • 7 comments

amitport avatar Feb 14 '17 09:02 amitport

@amitport try https://github.com/koajs/conditional-get

haoxins avatar Feb 14 '17 10:02 haoxins

@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

amitport avatar Feb 14 '17 11:02 amitport

Personally, I have CDN for production.

/cc @jonathanong

haoxins avatar Feb 15 '17 04:02 haoxins

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 :)

jonathanong avatar Feb 15 '17 04:02 jonathanong

@amitport can you add some tests for this ? :)

haoxins avatar Feb 15 '17 05:02 haoxins

@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.

amitport avatar Feb 15 '17 06:02 amitport

+1 on this

magicdawn avatar Apr 08 '17 04:04 magicdawn