# 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) <a name="config_type"></a> ### Config Type ### * [Include User-Agent properties](#UaProps) * [Include language properties](#LangProps) * [Client-side cookie name](#CookieName) <a name="UaProps"></a> #### 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 <a name="LangProps"></a> #### 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 <a name="CookieName"></a> #### 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" <a name="how_it_works"></a> ### 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. <a name="use_default_settings"></a> #### 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() ``` <a name="use_custom_settings"></a> #### 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() ``` <a name="config_examples"></a> ### 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 ``` <a name="general_tips"></a> ### General tips ### <a name="batch_processing"></a> #### 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 <!-- HTML+JS for document formatting when opened in browser --> <div class="btn-group" id="main-menu" style="float:right"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Menu<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="README.html">Main</a></li><li><a href="README.DeviceApi.html">Building dependencies and API</a></li><li><a href="README.DeviceApi-Web.html">Device Detection for Web</a></li><li><a href="README.DeviceApi-Apps.html">Device Detection for Apps</a></li><li><a href="./ApiDocs/device.html">Device API Docs</a></li><li class="divider"></li><li class="disabled"><a href="README.DeviceApi-Config.html">Device Detection API Config</a></li><li><a href="README.Upgrade.html">Device Detection API Upgrade</a></li><li class="divider"></li><li><a href="README.CarrierApi.html">Carrier Identification API</a></li><li><a href="./ApiDocs/carrier.html">Carrier API Docs</a></li><li class="divider"></li><li><a href="README.CarrierApi-Config.html">Carrier Detection API Config</a></li></ul></div>