Skip to content
This repository has been archived by the owner on Nov 6, 2021. It is now read-only.

Cache constantly regenerates because of different browscap versions... #2

Closed
quentin389 opened this issue Aug 14, 2013 · 2 comments
Closed

Comments

@quentin389
Copy link
Owner

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/

@ghost ghost assigned quentin389 Aug 14, 2013
@quentin389
Copy link
Owner Author

Temporarily fixed in version 1.2 by replacing the computed browscap version with a constant string. This means that if the browscap changes, the class will not see that, but seems like a good trade off for regenerating constantly.

Nevertheless has to be fixed property.

@quentin389
Copy link
Owner Author

Will be fixed properly along with #5
closing

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant