CacheToken Property (.NET)

Type: String

 

Turns on BrowserHawk's Automatic Session Caching (ASC) for the current user, and specifies the name of the session variable BrowserHawk uses to cache the Extended property tests results under.

 

By specifying a CacheToken, BrowserHawk will cache the results for the Extended property test. This makes it very efficient and convenient to use BrowserHawk results from multiple pages throughout your site, without having to manually write code to save BrowserHawk results to various session variables. See the topic on Automatic Session Caching (ASC) for detailed information on this feature.

 

Example (C#):

 

<%

// This example uses ASC, so there is no need to perform any session management yourself

ExtendedOptions options = new ExtendedOptions();

options.AddProperties("Plugin_Flash ");

// Tell BrowserHawk to use ASC and store the cached results into the session var named "bhawk_results"

options.CacheToken = "bhawk_results";

ExtendedBrowserObj extBrow = BrowserObj.GetExtendedBrowser(options);

// The first time GetExtendedBrowser executes for this visitor their browser will be tested.

// On subsequent requests, GetExtendedBrowser simply returns the cached ExtendedBrowserObj object

// without retesting the browser.

%>

<html>

Your Flash version is: <% = extBrow.Plugin_Flash.ToString() %> <br>

Results came from cache? <% = extBrow.IsFromCache.ToString() %>

</html>

 

Example (VB.NET):

 

<%

' This example uses ASC, so there is no need to perform any session management yourself

dim options as ExtendedOptions = new ExtendedOptions()

options.AddProperties("Plugin_Flash ")

' Tell BrowserHawk to use ASC and store the cached results into the session var named "bhawk_results"

options.CacheToken = "bhawk_results"

dim extBrow as ExtendedBrowserObj = BrowserObj.GetExtendedBrowser(options)

' The first time GetExtendedBrowser executes for this visitor their browser will be tested.

' On subsequent requests, GetExtendedBrowser simply returns the cached ExtendedBrowserObj object

' without retesting the browser.

%>

<html>

Your Flash version is: <% = extBrow.Plugin_Flash.ToString() %> <br>

Results came from cache? <% = extBrow.IsFromCache.ToString() %>

</html>

 

Caution: Do not attempt to access the cached ExtendedBrowserObj directly through the user's session. To get a cached ExtendedBrowserObj just call GetExtendedBrowser as usual, and if a cached version exists BrowserHawk will return it to you. Or, for more advanced usage, there is a GetFromCache method that returns the cached ExtendedBrowserObj object to you – this method may be handy if you are writing special dispatchers or handlers such as from HttpModules.

 

Tip: See the popular.aspx for a working sample that demonstrates use of this property.

 

See Also:

CacheForceRefresh Property (.NET)

IsFromCache Property (.NET)

Automatic Session Caching (ASC)

Understanding cyScape DashCache

Caching BrowserHawk Results