From AMF Wiki
The AMFDetectRightFilter and AMFDetectRightFilterMemcached are the modules of the suite they have the job to detect the device take the information from DetectRight (http://www.detectright.com) and pass the capabilities to the other AMF modules and as environment variables. The different between the first (AMFDetectRightFIlter) and the second (AMFDetectRightFilterMemcached) is the cache system.
Both modules does this two steps:
- load AMF parameters from httpd.conf
- load data from DetectRightAMF.xml
- and waiting for a useragent
The first step is to define the AMFMobileHome this is important for AMF because in this directory the AMF store the DetectRight.xml and the patch file (the patch file is an xml where are store the PC browser). The patch file is recommended to use.
In httpd.conf of Apache you define this parameter:
PerlSetEnv AMFMobileHome /home/AMF
where AMFMobileHome must be writeable. In the AMFMobileHome directory must be store the DetectRight.xml .
Settings for production environment
DetectRight for each mobile devices has more the 400 capabilities and normally for each mobile project don’t need all of them, so is suggested on the live web server to specify which capability you want to manage, the directive CapabilityList (default is set all):
PerlSetEnv CapabilityList brand_name,model_name,max_image_width
In this case you ask to AMF to manage only three capability, the list of all capability ask support at DetectRight site (http://www.detectright.com)
To increase performance on DeviceDetection is suggested to use the directive AMFProductionMode (default is false). In this mode the device has been detected only the first time that access on web server. In this mode the performance will be higher. The syntax is:
PerlSetEnv AMFProductionMode true
Pass User Agent on query string
This directive must be setted if you want to pass the user agent in query string, the syntax is to set RestMode (default is false):
PerlSetEnv RestMode true
In this mode it’s possible to pass the useragent on query string using the amf the sintax is:
If you have multiple virtual hosts and you need different configuration of AMF for each host remember to set this configuration in httpd.conf:
so in httpd.conf the syntax is:
PerlOptions +Parent <VirtualHost \ 192.168.100.3:80 \ 22.214.171.124:80 \ > ServerName default UseCanonicalName Off DocumentRoot /var/www/vhosts/default/htdocs ScriptAlias /cgi-bin/ "/var/www/vhosts/default/cgi-bin/" <IfModule mod_ssl.c> SSLEngine off </IfModule> # # AMF configuration # PerlSetEnv AMFMobileHome /root/AMF_home PerlSetEnv CacheDirectoryStore /tmp PerlSetEnv ResizeImageDirectory /tmp PerlTransHandler +Apache2::AMFDetectRightFilter <Location /img/*> SetHandler modperl PerlOutputFilterHandler Apache2::AMFImageRendering </Location> <Directory /var/www/vhosts/default/htdocs> <IfModule sapi_apache2.c> php_admin_flag engine on php_admin_flag safe_mode on php_admin_value open_basedir "/var/www/vhosts/default/htdocs:/tmp" </IfModule> <IfModule mod_php5.c> php_admin_flag engine on php_admin_flag safe_mode on php_admin_value open_basedir "/var/www/vhosts/default/htdocs:/tmp" </IfModule> </Directory> </VirtualHost>
Choose the cache system
AMF has two advanced cash system based on:
f you choose to adopted the file system caching you only need to configure the CacheDirectoryStore parameter, this directory must be writable we suggest to not use the /tmp directory in production servers. The syntax is:
PerlSetEnv CacheDirectoryStore /tmp PerlTransHandler +Apache2::AMFDetectRightFilter
The last directive load the module.
For memcached it’s need to configure ServerMemCached the syntax is:
PerlSetEnv ServerMemCached <address:port>,<address2:port>,....,<addressn:port>
PerlSetEnv ServerMemCached localhost:11211,10.10.10:11233 PerlTransHandler +Apache2::AMFDetectRightFilterMemcached
The last directive load the module.
How can I retrieve the values of the capabilities of DetectRight ?
Retrieve the DetectRight capabilities value is very simple, all the informations are setting into the Apache Environment as AMF_<uppercase DetectRight capabilities name> for example:
To read the DetectRight capabilities max_image_height you must read the environment value AMF_MAX_IMAGE_HEIGHT.
The php code is:
a test page in php is downloadable:
Before in the httpd.conf file where you have to configure mod_jk you muse add this:
JkEnvVar AMF_MAX_IMAGE_HEIGHT undefined
The Java code is: