PHP accurately and quickly identifies UA: user-agent, which can be obtained in the server variables provided by PHP. What is the purpose of user-agent identification? 1. what browser is it? This is no longer required. The HACK of CSS can help you correctly render the image in a browser. 2. browser type: this is definitely required for precise and fast UA identification in PHP
UA: the user-agent is available in the server variables provided by PHP. What is the purpose of user-agent identification?
1. what browser is it? This is no longer required. The HACK of CSS can help you correctly render the image in a browser.
2. browser type: this is mandatory. what we want most is to know whether it is in a PC or a mobile phone. in this way, we can select different pages.
3. user-agent: On the surface, it is the same concept as the browser type, but it is actually different. The user-agent has a wider range than the browser type. Because, visitors not only have browsers, but also applications, search robots, and spam websites to capture information. For Spam websites that come to capture information, of course, many of them are disguised. to deal with it, it is not handled in UA identification, but in IP routing.
In MVC mode, the most important reason for UA routing is to make the client request to display the correct page.
However, PHP does not have good functions, or is scalable and can be maintained by a third-party open-source, which can be used to quickly identify UA.
Although the get_browser function is of the C language level, the INI files related to it need to be downloaded in real time, and a large INI file of several hundred kb should be searched for the correct UA. then, the corresponding results are calculated based on different algorithms. when the efficiency is high, of course, the download speed is not good, or the process is too large, the machine memory is tight and the speed will immediately decrease. This is a tragedy.
?
The best practice is to completely split all UA strings, and we will find that some strings must be ROBOT proprietary and some strings must be MOBILE proprietary. As a result, to make a CSV, the current data is only a file with less than 1000 records in two fields. The file size is reduced to 20 kB. The data to be processed is reduced by about 25 times. The speed is 20 times faster than the original speed, and more than 200 times faster than the original speed.
?
Why? How many times does it take to find 1000 records in half? In addition, if 1000 rows of records are not found in 20 KB text, it is much faster than searching for more than 400 rows of configuration records that cannot be searched in more than 20 thousand KB files.
?
?
?
?