Skip to content

Cache accepts Instance in Request Methods? #5906

Open
@IamLizu

Description

@IamLizu

The current implementation of the req.accepts, req.acceptsEncodings, and req.acceptsEncoding methods in lib/request.js creates a new accepts instance for each call.

Am I correct to think that this can lead to redundant object creation and parsing overhead, especially in scenarios where these methods are called multiple times within the same request lifecycle?

If caching the accepts instance seems correct to reduce overhead and help with faster execution, I am willing to create PR and benchmark comparisons for this. However, since I have very little idea about the overall scenario I need a confirmation of go / no go.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions