The caching mechanism has a built-in version check for all the source parser files.
Browscap version is checked using filesize(ini_get('browscap'))
, as it is a good enough approximation of the file contents.
The problem is that when you're running a multi server configuration and each server uses its own browscap file, not the one supplied with this class (available in imports/browcap.ini
), the files may differ on each server. If that happens and you have a cache that is common for all the servers then the cached UserAgentInfo
objects will constantly be invalidated and regenerated, slowing down the servers, as parsing ua strings is a costly operation.
This is not a bug, the class actually behaves correctly, because the parsing results using different browscap version will differ. However, it is an issue, because it's not obvious that this can happen.
The proper way to fix it, without changing anything in UserAgentInfo
project is to force your admins to keep the browscap files updated on all the servers, or to point the servers to UserAgentInfo
internal browscap.ini
file.
However, since that requires changes on the servers, it may not always be an option, it may take long time to change, and so on and so forth.
This will stop being an issue when I stop relying on browscap php.ini
configuration and the PHP module for browscap. Using this module is not a good idea for other reasons (such as: required server configuration and parsing speed), so this issue is another important reason to start using browscap fully in PHP, as it is shown in https://github.com/GaretJax/phpbrowscap/