Hummingbird acts weird with the custom code to detect user agents.

I have set up custom code to detect the user agent. Hummingbird behaved weirdly with the custom code.
Hummingbird caches that user agents.
Example :
if one user opened the website from his phone, his user agent will be cached.
So if another user opens from the desktop, he will get the user agent of the phone user and functions gets messed up.