# DeviceAtlas Data File Optimizer # Optimization for downloaded data file inside a web application. ### Overview ### In a web application, the first request after a data file update will experience a small lag. To eliminate this lag, it is necessary to optimize the data file. This tool pre-optimizes a data file downloaded from the DeviceAtlas website. The API will then directly use the optimized data. Note: To manually update the optimization cache with this command line tool it is recommended to turn off the DeviceApi data file changes check which would be unnecessary: **Inside a web application** ```php use DeviceAtlas\Device\DeviceApiWeb; use DeviceAtlas\Device\Config; $config = new Config(); $config->setIgnoreDataFileChanges(true); $deviceApi = new DeviceApiWeb($config); $deviceApi->loadDataFromFile(<data file path>); ``` **Optimize the data file** The following command can be run once there is new data file. ```bash php ExtraTools/data-file-optimizer/main.php -d /path/to/datafile.json ``` ### Other usages ### **Clear the optimization cache** ```bash php ExtraTools/data-file-optimizer/main.php -c ``` **Analyses speed and memory performance** ```bash php ExtraTools/data-file-optimizer/main.php -a /path/to/datafile.json ``` #### Custom temp directory #### By default, the optimized data caches will be put inside the system temp directory, however it can be changed using this config option: ```php $config->setOptimizerTempDir('/path/to/my/temp-directory'); ``` When using custom temp directory, this information must be also passed to the script: ```bash php ExtraTools/data-file-optimizer/main.php ... -t /path/to/my/temp-directory ``` e.g. ```bash php ExtraTools/data-file-optimizer/main.php -d /path/to/datafile.json -t /path/to/my/temp-directory php ExtraTools/data-file-optimizer/main.php -a /path/to/datafile.json -t /path/to/my/temp-directory php ExtraTools/data-file-optimizer/main.php -f /path/to/datafile.json -t /path/to/my/temp-directory ``` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _ Copyright (c) DeviceAtlas Limited 2023. 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.DataFile.html">Data File Configuration</a></li><li><a href="README.DeviceApi.html">Device API Usage</a></li><li><a href="README.ClientHints.html">Client Hints Support</a></li><li class="disabled"><a href="README.DataFileOptimizer.html">Data File Optimizer</a></li><li><a href="README.Upgrade.html">Device API Upgrade</a></li><li><a href="README.CarrierApi.html">Carrier Identification API</a></li><li class="divider"></li><li><a href="./ApiDocs/index.html">DeviceAtlas API Docs</a></li></ul></div>