selwin / django-user_agents

A django package that allows easy identification of visitor's browser, OS and device information, including whether the visitor uses a mobile phone, tablet or a touch capable device.
MIT License
640 stars 104 forks source link

Caching is unnecessary #18

Open Chronial opened 7 years ago

Chronial commented 7 years ago

Caching the results seems unnecessary https://github.com/selwin/django-user_agents/blob/master/django_user_agents/utils.py#L41, since uap-python doesn't actually load the yamls anymore, but they are converted to python in the build process.

See here https://github.com/ua-parser/uap-python/blob/master/setup.py#L20 and here https://github.com/ua-parser/uap-python/blob/master/ua_parser/user_agent_parser.py#L548.

So this is loaded and imported once and then cached by the python importing system anyways.

acu192 commented 4 years ago

I agree. In fact, caching will likely be slower than simply re-parsing the UA on each request. A warmed-up parser takes microseconds to parse the UA. See below:

Screen Shot 2020-02-24 at 1 01 59 PM Screen Shot 2020-02-24 at 12 53 23 PM

No reason to put this extra burden on your cache server when it doesn't help you at all.

boatcoder commented 2 years ago

I'm also seeing some issues with redis parsing and ua-parser==0.15.0 as well. Haven't managed to pin it down yet though.