-
Notifications
You must be signed in to change notification settings - Fork 98
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
Reduce number of stat calls #21
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 254 271 +17
=====================================
+ Hits 254 271 +17
Continue to review full report at Codecov.
|
src/index.js
Outdated
response.end(err.message); | ||
// It's extremely important that we're doing multiple stat calls. This one | ||
// right here could technically be removed, but then the program | ||
// would be slower. Cause for directories, we always wanna see if a related file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Proper English would be nice for code comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
Previously, the package was firstly checking the existence of the requested path and then seeing if related paths like
<path>/index.html
exist.However, since directory listings are not the most common use case of this package (but rather rendering files and static projects), I decided to move this further down the line.
As a result, if you request
/
, the firststat
call will no more be for the directory/
, but rather for/index.html
, as long ascleanUrls
or a respectiverewrites
item is enabled.🎉 This is not a breaking change, it only reduces the number of
stat
calls to be made until a file is reached and sent back to the client.🍏 I also added 6 more tests, in addition to the existing ones passing. We now have 45!