Giter Site home page Giter Site logo

Comments (2)

serbanghita avatar serbanghita commented on June 1, 2024

Is there any reason isMobile() method doesn't cache matches in matchDetectionRulesAgainstUA()?

This is a mistake on my part, I should have cached this, but probably at that point I realized that my cache key should be based on userAgent string value. In matchUAAgainstKey I used the name of the method which is probably not that great to begin with. I probably avoided to create a cache key based on User Agent string + HTTP headers array

If you call isMobile() and then isIphone it'll run match again while it could be cached.
Also if you run isIPhone() the result will be cached, but then if you run isMoible() the cache won't be used.

As a side note - I'm not sure why match() method is public. it is not useful since by itself it doesn't detect anything.

Should be protected, probably I was thinking to allow people to use custom regexes.
Might be a good idea to make it protected and then whoever extends MobileDetect can work with it.
This is clearly a bug. setUserAgent resets the $cache.
I will fix this and cache based on User Agent string + HTTP headers array

from mobile-detect.

serbanghita avatar serbanghita commented on June 1, 2024

I have fixed this in https://github.com/serbanghita/Mobile-Detect/releases/tag/4.8.01
This is a major refactor, I added support for PSR-16 cache

@npelov Nikolay, thank you for the detailed write-up, it helped me get motivated to release this new version with fixes.

from mobile-detect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.