[lp_client_browser]

Description

Link: [lp_client_browser]
Author: Bil Corry
Category: Client
Version: 8.x
License: Public Domain
Posted: Jan. 20, 2006
Updated: Mar. 17, 2008
More by this author...

Returns the name, version, OS, type and typecode of the client browser in a map.

 

Browser types:
    B = Browser
    C = Link/Bookmark/Server Checker
    D = Download/FTP tool
    E = Email Reader
    F = Feed Reader
    L = Library
    O = Offline Browsing
    P = Proxy, Web filter
    R = Robot/Crawler/Spider
    S = Spam Harvester, Bad Bot
    U = Unknown
    V = HTML/CSS/JS Validator
    X = Suspected Robot/Crawler/Spider

Parameters

-user_agent string, optional Parses the user-agent string provided. Default is to process the current client user-agent string.

Sample Usage

lp_client_browser->(find:'browser');
lp_client_browser->(find:'version');
lp_client_browser->(find:'os');

(lp_client_browser: 'Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.6) Gecko/20040207 Firefox/0.8')->(find:'browser');
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

lp_client_browser.zip (28.77 kb)

 

Comments

01/30/2008, Johan Sölve
Correction
After realizing that the browser config variables should be globals instead of vars or locals (so they don't have to be defined each time), execution time without cache is now 5-6 ms compared to 2-4 ms with cache. In other words, not much to gain with the caching. I'm withdrawing my suggested changes.
01/30/2008, Johan Sölve
Small adjustments [trying better formatting]
I moved the browser profile config vars into the ctag (and changed them to locals) to make it more self-contained (also seems slightly faster actually), and I also added caching in a global (limited to 10000 entries) so client_browsers we have seen before will have the info returned immediately without further processing. Cached client types are returned in 2-3ms instead of 75-80ms on my MacBook.

Code additions for the cache (it would also need thread locking to be completely safe) --
near the beginning:
if: (global: '_lp_client_browser_cache') >> #client_browser;
return: $_lp_client_browser_cache -> find(#client_browser);
/if;

and near the end:

!(global: '_lp_client_browser_cache') -> isa('map') ? global: '_lp_client_browser_cache' = map;
if: $_lp_client_browser_cache -> size < 10000 && $_lp_client_browser_cache !>> #client_browser;
$_lp_client_browser_cache -> insert(#client_browser = #return);
/if;

return: #return;
01/30/2008, Johan Sölve
Small adjustments
I moved the browser profilee config vars into the ctag (and changed them to locals) to make it more self-contained (also seems slightly faster actually), and I also added caching in a global (limited to 10000 entries) so client_browsers we have seen before will have the info returned immediately without further processing. Cached client types are returned in 2-3ms instead of 75-80ms on my MacBook. Code additions for the cache (it would also need thread locking to be completely safe) -- near the beginning: if: (global: '_lp_client_browser_cache') >> #client_browser; return: $_lp_client_browser_cache -> find(#client_browser); /if; and near the end: !(global: '_lp_client_browser_cache') -> isa('map') ? global: '_lp_client_browser_cache' = map; if: $_lp_client_browser_cache -> size < 10000 && $_lp_client_browser_cache !>> #client_browser; $_lp_client_browser_cache -> insert(#client_browser = #return); /if; return: #return;
Email:


Password:



Newest

Most Popular