# DeviceAtlas Device Detection API Config #
Device Detection API Config provides options to customize the way the API
behaves in terms of memory use, caching, performance and device properties.
## Contents ##
* [DaConfig type](#config_type)
* [How it works](#how_it_works)
* [Configuration examples](#config_examples)
* [General tips](#general_tips)
### Config Type ###
* [Include User-Agent properties](#UaProps)
* [Include language properties](#LangProps)
* [Client-side cookie name](#CookieName)
#### Include User-Agent properties ####
Boolean value to enable/disable the addition of User-Agent properties to the
detection. They are also known as "dynamic" properties as they can be detected
on the fly by directly parsing the User-Agent.
Enabling this field will reduce API detection performance. If dynamic properties
are not needed, set it to `false`.
User-Agent/Dynamic properties: `browserName, browserVersion,
browserRenderingEngine, osName, osVersion`
**Config field:** `DaConfig.UaProps`
**Possible values:** true/false
**Default Value:** true
#### Include language properties ####
Boolean value to enable/disable the addition of client's language and locale
preferences to the device property set.
If these properties are not needed, it should be set to `false`.
Language properties: `language, languageLocale`
**Config field:** `DaConfig.LangProps`
**Possible values:** true/false
**Default Value:** true
#### Client-side cookie name ####
Name of the cookie where the Client-side properties will be saved in.
When using Detect/DetectV() method in a web application (DeviceApi), the
detection will automatically use the content of this cookie, if it exists.
If you want the Client-side properties to be used add the DeviceAtlas client
side component (JavaScript lib) to your web-site pages.
If you set the cookie name to empty string, then the Client-side properties cookie will
be ignored.
**Config field:** `DaConfig.CookieName`
**Default Value:** "DAPROPS"
### How it works ###
This section describes how to use the `DaConfig` type to
modify the behavior of the `deviceatlas.device.DaGo` instance
when performing the device properties lookup.
#### Use of the default settings ####
When a new instance of the `deviceatlas.device.DaGo` is created,
internally another instance of the `DaConfig` type is generated
with the default settings.
```go
da := device.New()
defer da.Free()
```
#### Use of custom settings ####
In order to use custom settings, it is required to explicitly create a
`DaConfig` object, configure the settings and pass it to the
`deviceatlas.device.DaGo` instance.
**Preferred method**
```go
config := &device.DaConfig{CookieName:"DAPROPS", UaProps: true, LangProps: true}
da := device.New()
defer da.Free()
da.Config(config)
...
alternatively
...
config := &device.DaConfig{CookieName:"DAPROPS", UaProps: true, LangProps: true}
da := device.NewWithConfig(config)
defer da.Free()
```
### Configuration examples ###
In order to enhance performance, reduce memory footprint and, in general,
provide a better user experience, it is highly recommended to configure
the API with the most convenient settings for a given use case.
```go
var config *device.DaConfig
config = device.NewConfig()
// Boost API performance by ignoring dynamic properties if they
// are not part of the expected property set.
config.UaProps = false
// Ignore language and locale properties if they are not needed.
config.LangProps = false
```
### General tips ###
#### Maximizing CPU utilization ####
The latest version of the device API runs without problems in a
multi-process environment, however custom code must be created to access the API
in a multi-process way to achieve the optimal hardware utilization.
The following are general recommendations to obtain optimal results from the hardware:
* A single device API instance can be used in a goroutine context.
* The default GOMAXPROCS value can be used or can be adjusted to use a subset of available cores.
* The recommended number of concurrent processes should not be greater than
the number of cores in the system.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_ Copyright (c) DeviceAtlas 2022. All Rights Reserved. _
https://deviceatlas.com