From AMF Wiki
The AMFWURFLFIlter and AMFWURFLFilterMemcached are the modules of the suite they have the job to detect the device take the information from WURFL (trademark of ScentiaMobile, inc) and pass the capabilities to the other AMF modules and as environment variables. The differnet between the first (AMFWURFLFIlter) and the second (AMFWURFLFilterMemcached) is the cache system.
Both modules does this two steps:
- load AMF parameters from httpd.conf
- load data from wurfl.xml and/or patch file and store in memory
- 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 wurfl.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 wurfl.xml (downloadable from http://downloads.sourceforge.net/wurfl/wurfl-latest.zip) . AMF has another option, it’s to download directly from a host the WURFL file, and the directive for this option is describe below:
PerlSetEnv WURFLNetDownload true PerlSetEnv DownloadWurflURL http://downloads.sourceforge.net/wurfl/wurfl-latest.zip
WURFLNetDownload default value is 'false'
if you need to detect web browser you need to put on true the LoadWebPatch (default is false):
PerlSetEnv LoadWebPatch true
The Web Patch is not more supported from AMF v3.53 because WURFL has integrated the web patch into the wurfl file.
There is another option that AMF can manage, is the PersonalWurfFile, some time for some reason is necessary to add new useragent or strange useragent, with this directive you can create your xml like this:
<wurfl_patch> <devices> <device user_agent="mickey mouse" fall_back="root" id="generic"> <group id="fb"> <capability name="mynewcapability" value="false"/> </group> </device> <device id="apple_iphone_ver4_3"> <group id="fb"> <capability name="mynewcapability" value="true"/> </group> </device> </devices> </wurfl_patch>
and then put it in the AMF_Home directory, and set PersonalWURFLFile:
PerlSetEnv PersonalWurflFileName mywurfl.xml
Settings for production environment
WURFL 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 is described at wurfl site (http://wurfl.sourceforge.net/help_doc.php)
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 \ 188.8.131.52: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::AMFWURFLFilter <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::AMFWURFLFilter
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::AMFWURFLFilterMemcached
The last directive load the module.
How can I retrieve the values of the capabilities of wurfl ?
Retrieve the WURFL capabilities value is very simple, all the informations are setting into the Apache Environment as AMF_<uppercase wurfl capabilities name> for example:
To read the WURFL 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: