-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
added accepted options for etag #105
Conversation
You cannot send back a strong ETag without being able to guarantee the bytes will be identical, i.e. you need to at least take a hash of the file contents. In order for strong Etags to be an option in this module, you need to add this functionality. Please also ensure that it does not buffer the entire file contents into memory, as the files can be quite large. |
@@ -59,7 +59,9 @@ the 4th byte in the stream. | |||
|
|||
##### etag | |||
|
|||
Enable or disable etag generation, defaults to true. | |||
Accepts `'weak'`, `'strong'`, custom function `function(data){ return etag}`, |
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.
It is not clear what the "data" argument is in the documentation. Please elaborate in the document what this is and what it contains.
I thought strong etags are properly generated in etag package, but as I see they are not, wouldn't it be better to add it there ? |
You're only giving the etag package a stat object, which does not contain enough information to generate a strong ETag. If you want to add strong ETag support, here are the requirements:
|
I think you misunderstand the requirements for that change, because the change does not require any changes to be made to any dependencies. |
Yes, I saw your comment on it. Anyway I think strong etags should be added. So I will first finish expressjs/express#2936 and then take a look at this. |
I don't agree that it is even worth it. Not even nginx of Apache give you this for files, because a file can be 800MB, and computing a hash can take significant time and resources, providing a very simple path to DoS a server from many repeated file requests. I'm going to close the pull request, on the grounds for the highlighted issues above. If you are interested in adding strong ETags here, please keep the requirements I highlighted above, and you may want to research pitfalls and the reasons other servers don't do strong ETags for files so you can't take into account all the prior research and implementations that have already been done. |
This PR adds funcionality for setting etags, 'weak' 'strong' custom function, without breaking back compatibility.
Needed for expressjs/express#2936