Skip to content

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

Open
amitport wants to merge 1 commit into
koajs:masterfrom
amitport:patch-1
Open

don't read to file when the browser cache is valid#69
amitport wants to merge 1 commit into
koajs:masterfrom
amitport:patch-1

Conversation

@amitport

Copy link
Copy Markdown

No description provided.

@haoxins

haoxins commented Feb 14, 2017

Copy link
Copy Markdown
Member

@amitport

Copy link
Copy Markdown
Author

@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

@haoxins

haoxins commented Feb 15, 2017

Copy link
Copy Markdown
Member

Personally, I have CDN for production.

/cc @jonathanong

@jonathanong

Copy link
Copy Markdown
Member

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

@haoxins

haoxins commented Feb 15, 2017

Copy link
Copy Markdown
Member

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

@amitport

amitport commented Feb 15, 2017

Copy link
Copy Markdown
Author

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

@magicdawn

Copy link
Copy Markdown

+1 on this

@haoxins haoxins self-assigned this Apr 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants