-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why yield next #9
Comments
that's correct, in this one we're currently letting it go all the way downstream and then determining if something else handled it. That's one of the gotchas with "proper" middleware, but I think both cases are valid, I'd like to support both see #8 |
i think this is the right approach when your static files change during production or when you're developing. i wouldn't want a stat call on every single request made on my production server. that's why i wrote https://github.com/koajs/static-cache for production, which doesn't use a single stat call except during initialization. |
in production you'd either use something like varnish or a cdn (that's why I wouldn't bother with it in node), but there are some exceptions, and you can set up nginx to route certain paths in prod, but maintain the same behaviour in node |
yeah, static-cache is an over optimization. i'm averse to infrastructure though, especially for simple stuff. people are still going to |
I can see why you'd want to put your static middleware last for certain applications, but not why you wouldn't just respect the user's choice - i.e. recommend putting static last rather than first. The |
Thanks for confirming what it does though. That has helped me understand :) |
I'll doc this better in the readme too, it's a little confusing when you're coming from Connect since it looks the same. I do think supporting both is good though, especially when mounting; stat() first makes sense |
Perhaps make it default to connect's behavior, which is intuitively what most people would expect, and then have a |
agreed! |
I'm trying to get to grips with how koa is built. What is the purpose of
yield next
: index.js#L36Am I right in thinking that static files are only served if the request is not handled by any other method? That seems really backwards compared to express's nice waterfalling semantics. It's simple to read an express app as "try this then try that then try that then try that" and it just stops once a method succeeds in handling the request. How would something like the following work:
The text was updated successfully, but these errors were encountered: