jshttp / negotiator

An HTTP content negotiator for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caching the availableMediaTypes

s-ko-mo opened this issue · comments

Hello,

currently the incomming request is given to the constructur of 'Negotiator' and the 'availableMediaTypes' to 'negotiator.mediaTypes'. So for each request a new Negotiator instances needs to be created and the availableMediaTypes are prepared (at https://github.com/jshttp/negotiator/blob/master/lib/mediaType.js#L174)

Think changing the API constructor and availableMediaTypes is not possible due to backward compatibility. But maybe a new function which allows reusing the perpared priorities of the availableMediaTypes would be nice.

Thanks and kind regards,
Sven

It would be really nice to cache the output. I am using this in my framework - fortjs. I am working on optimization and found that if we can cache the negotiation part which is same most of the time, then it would be great.

Please add this feature.