Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow requests #27

Open
efraimt opened this issue May 17, 2020 · 4 comments
Open

Slow requests #27

efraimt opened this issue May 17, 2020 · 4 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@efraimt
Copy link

efraimt commented May 17, 2020

Hi,

First of all I appreciate the amazing work that you did and gave the community for no profit.

Sadly, I don't have right now the ability to write some code that will do some improvements myself :(
I was wondering if the .NET version uses any cache system, queries are really slow even on strong servers.
I also was wondering if there is a way to write code that will get every time the updated YML's?

Thanks again

@totpero
Copy link
Owner

totpero commented May 17, 2020

Hi @efraimt thanks for your feedback,
In this project is implemented static Dictionary cache, you can use it like this:

var dd = new DeviceDetector(userAgent);

// OPTIONAL: Set caching method
// By default static cache is used, which works best within one php process (memory array caching)
// To cache across requests use caching in files or memcache
// add using DeviceDetectorNET.Cache;
dd.SetCache(new DictionaryCache());

But can be created other cache implementation like redis cache.

The YAML file is embeded in project but if you want to update manually the yaml files from the original php repo you can use static location like this:
DeviceDetectorSettings.RegexesDirectory = @"C:\YamlRegexsFiles";
And there you can update your yaml.

I was very busy this time but i will update the project to day;
If you want or some one else can create pull request with all update from php repo and i will merge it in this.
Thanks

@totpero
Copy link
Owner

totpero commented Jul 26, 2020

@efraimt Try to use this see if works.

@stbentia
Copy link
Contributor

Hi, I checked in a pull request to add a persistent cache for the results of Parse calls. @efraimt Please see if that helps.

@ragasjohn
Copy link

ragasjohn commented Feb 24, 2024

Hello to all,
I have the same problem on an .net API I am using.
The requests sometimes take 50ms to complete.

I am using it like this

` var userAgent = httpContext.Request.Headers["User-Agent"];//.UserAgent;

var detector = new DeviceDetector(userAgent);
detector.Parse();

if (detector.IsBot())
{
return "Bot"; // Handle bots separately if needed
}

if (detector.IsDesktop())
{
return "Desktop";
}
else if (detector.IsTablet())
{
return "Tablet";
}
else if (detector.IsMobile())
{
return "Mobile";
}
else
{
return "Unknown";
}`

I do not want to use caching since this it costs more to use it per session. I have millions of request to my API

Any help appreciated

Thanks
Yannis

@totpero totpero added help wanted Extra attention is needed question Further information is requested labels Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants
@totpero @ragasjohn @stbentia @efraimt and others