Enter Case number reference for associated cases.

Case #

Status:

Type: APM as a Service

Old Article ID: 4360

Old Article Type: howto

 

Information:

Detail the contextual information specific to the issue; i.e. Product, Version, Agent, System, etc.

  • Windows Recorder

 

Describe the problem, from the user perspective

Many customers may have questions about the browser cache :

  • Does the Browser Agent clear the browser cache after each test run?
  • Can I create a test that uses the browser cache?
  • How can I refresh the web page in a test?
  • What is the Repeat Visitor function in the Windows Recorder?

Clearly list the Steps to resolve the issue

When a test runs in the Synthetic Classic Portal, the browser cache is cleared after each test run.

To create a test that uses the browser cache, first consider how the cache is used:

Generally, browsers create a cache of the web pages you visit to load the page faster for subsequent visits to the page. But whether a browser uses the cache depends on the user's actions and the cache control HTTP headers.

To create a test that uses the cache or refreshes the target page, there are three possibilities:

  • Visit the same page twice, the second time retrieving the page from the browser cache, and get the result of the second visit.
  • Emulate pressing F5 to refresh the page.
  • Emulate pressing Ctrl+F5 to refresh the page.

Each of these scenarios can be triggered by a JavaScript function in a Recorder script. The following table lists the keyboard action and equivalent JavaScript function for them:

Browser ActionKeyboard ActionJavaScript
Re-visit the pageAccess the same URL againlocation.replace(location.href)
RefreshPress F5location.reload(false)
Force RefreshPress Ctrl+F5location.reload(true)

In Internet Explorer, Firefox, and Chrome, the page is cached when you first visit a web page. Then:

  • If you re-visit the page, the browser reads the cache first, and then sends the requests only to those objects that don't have an Expire header or that have an Expire header but are expired.
  • If you refresh this page with F5, the browser sends a request to all objects, but adds additional HTTP headers (such as If-Modified-Since) to check with the server to see if the object has expired. If the object has not been changed on the server side, the server replies with the response code 304: not modified.
  • If you force-refresh the page with Ctrl + F5, the browser sends requests to all objects, with some additional HTTP headers (such as Cache-Control: no-cache), ignoring the local cache. Therefore, every object is loaded again.

This table summarizes browsers behaviors:

Action NameSend request to all HTTP objectsIE additional headerFirefox additional header
Re-visitNo*--
RefreshYesIf-Modified-Since:XXXX**If-Modified-Since:XXXX**
Cache-Control: max-age=0
Force RefreshYesCache-Control: no-cacheCache-Control: no-cache
Pragma: no-cache

* The browser will read the cache, then only send requests to those objects that don't t have an Expire header or that have an Expire header but have expired.
** The XXXX in If-Modified-Since:XXXX means the expiration time of the cache content.

The attached scripts Re-Visit.gsl,F5-Refresh.gsl and CtrlF5-Refresh.gsl demonstrate how the local cache works and how to create a script with a local cache. Since the Browser Agent agent cleans the cache after each test run, the script needs to load the same page in Step 1 to generate the cache. That means you cannot create a one-step test to see the result for re-visit, refresh or force refresh.

Repeat Visitor

The Repeat Visitor feature in the Windows Recorder is a solution for Re-visit. This feature is only available for the IE Agent. If you enable Repeat Visitor, it runs the same test twice in the same browser window, using the cached page for the second run; only the response time data for the second run is stored in the Synthetic Classic database.