Skip to content
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

Merged
merged 10 commits into from
Jun 6, 2018
Merged

Reduce number of stat calls #21

merged 10 commits into from
Jun 6, 2018

Conversation

leo
Copy link
Contributor

@leo leo commented Jun 6, 2018

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 first stat call will no more be for the directory /, but rather for /index.html, as long as cleanUrls or a respective rewrites 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!

@leo leo added the enhancement New feature or request label Jun 6, 2018
@leo leo requested a review from timneutkens June 6, 2018 14:20
@codecov
Copy link

codecov bot commented Jun 6, 2018

Codecov Report

Merging #21 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #21   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines         254    271   +17     
=====================================
+ Hits          254    271   +17
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bbb5fd1...f666a6d. Read the comment docs.

@leo leo requested review from OlliV and removed request for timneutkens June 6, 2018 14:42
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
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@leo leo merged commit c3df8a1 into master Jun 6, 2018
@leo leo deleted the special-case-prod branch June 6, 2018 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants