CacheForceRefresh Property (.NET)

Type: Boolean

 

When set to True, forces BrowserHawk to disregard any previously cached test results for the current visitor and retest their browser.

 

There may be situations where you want to force BrowserHawk to retest a browser, even though the information is already in the cache.

 

For example, let's say you test a browser for a required screen size and the user's screen size is too small. You then provide the user with information on how to increase their screen size and provide a link for them to retry the test to confirm their new settings are correct.

 

If you do not force a clear of the cached information, BrowserHawk will continue to return their original screen size test results from the cache. Therefore, in such situations, you will want to force BrowserHawk to retest the browser.

 

For more information see the topic Automatic Session Caching (ASC).

 

Note: The CacheForceRefresh property must be set to True prior to calling the GetExtendedBrowser method for this setting to have an effect.

 

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";

// See if we've been asked to clear the cache by looking for such a command in the query string

if (Request.Params["bhClear"] != null) {

options.CacheForceRefresh = true;

}

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() %>

<a href="thispage.aspx">Click here to retest without clearing cache</a><br>

<a href="thispage.aspx?bhClear=1">Click here to clear the cache and retest</a>

</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"

if (NOT Request.Params("bhClear") IS Nothing) then

options.CacheForceRefresh = true

end if

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() %>

<a href="thispage.aspx">Click here to retest without clearing cache</a><br>

<a href="thispage.aspx?bhClear=1">Click here to clear the cache and retest</a>

</html>

 

Tip: In these examples we used bhClear=1 in the query string as a flag to our script to indicate we want to force a cache refresh. You can use whatever parameter or mechanism for this you want. For instance you could have a dedicated "retest your browser page" that always sets CacheForceRefresh to true. Using a switch such as a querystring parameter as demonstrated in this sample is a good way to force a refresh of the cache conditionally, based on your particular needs.

 

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

 

See Also:

CacheToken Property (.NET)

IsFromCache Property (.NET)

Automatic Session Caching (ASC)

Understanding cyScape DashCache

Caching BrowserHawk Results