- Common API
- Updating Device Data
- Useful Links
- Supported Versions
Updating Device Data
Keeping device data up-to-date is almost as important as regularly installing security updates as it affects your customers. Correctly identifying the latest devices, Operating Systems and browsers allows you to provide your customers with the most relevant version of your website and content. Our data team work tirelessly to update our database on a daily basis.
We understand that manually downloading the latest data file is time consuming and inefficient, so we have introduced automatic updates functionality. This allows your API to automatically retrieve the latest data file from our servers using your licence key and update your current device data file with the latest version.
If you are a Premium or Enterprise customer you can get started with automatic data updates straight away, see the next section for more details. Lite data users are welcome to test drive automatic updates by signing up with our free evaluation programme. When trialling the Premium and Enterprise data file versions you can experience the benefits of having more properties and device combinations as well as more frequent updates. Compare the features offered by each data file.
For general information about the auto update feature see the Automatic Data Updates documentation page.
PHP Specific Information
The PHP common API now supports automatic updates which running an On-Premise installation. Automatic updates is realised by calling the ‘update.php’ script found in the common API directory. To enable automatic updates, you will need to set up a scheduled job:
It is important that the data file has the correct permissions to be accessed by the webserver, this can be done by setting the owning user/group to that of the webserver or updating the ‘ rwx ’ permissions on the datafile. E.g. ‘ chmod 755 /var/www/html/51Degrees-EnterpriseV3.2.dat ’
- - Create a bash script called ‘ 51DUpdate.sh ’ with the contents: content=$(curl -L localhost/update.php)
- - Save this in /etc/cron.daily/
- - Run crontab -e
- - Append the following line to enable automatic updates: 0 0 * * * /etc/cron.daily/51DUpdate.sh
The cron job will now execute every day at midnight, the script will make a request to the ‘update.php’ script. The script will download and update the existing data file then reload the provider.
To prevent users from forcing an update it is recommended that access to the ‘update.php’ file is denied from external interfaces.
On windows, automatic updates can be enabled using a PowerShell script that is run via scheduled task. To set up automatic updates on Windows, make a PowerShell script called 51DUpdate.ps1 with the contents:
$content = Invoke-WebRequest http://localhost/
A Scheduled Task can be used to run this script with a frequency of once a day. As the most frequently updated data file is released daily, there is little to no benefit to running this more than once per day.